File indexing completed on 2025-11-29 10:01:19
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <iomanip>
0010 #include <ostream>
0011
0012 #include "Span.hh"
0013
0014 namespace celeritas
0015 {
0016
0017
0018
0019
0020 template<class T, std::size_t E>
0021 std::ostream& operator<<(std::ostream& os, Span<T, E> const& s)
0022 {
0023 std::streamsize size = s.size();
0024 std::streamsize width = os.width();
0025 std::streamsize remainder = 0;
0026
0027 os.width(0);
0028 os << '{';
0029 if (width > 2 + (size - 1))
0030 {
0031
0032 width -= 2 + (size - 1);
0033
0034
0035 remainder = width % size;
0036 width = width / size;
0037 }
0038 else
0039 {
0040 width = 0;
0041 }
0042
0043
0044 os.width(width + remainder);
0045 if (!s.empty())
0046 {
0047 os << s[0];
0048 }
0049
0050 for (std::streamsize i = 1; i < size; ++i)
0051 {
0052 os << ',';
0053 os.width(width);
0054 os << s[i];
0055 }
0056 os << '}';
0057
0058 return os;
0059 }
0060
0061
0062 }