Warning, file /include/corecel/cont/SpanIO.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <iomanip>
0011 #include <ostream>
0012
0013 #include "Span.hh"
0014
0015 namespace celeritas
0016 {
0017
0018
0019
0020
0021 template<class T, std::size_t E>
0022 std::ostream& operator<<(std::ostream& os, Span<T, E> const& s)
0023 {
0024 std::streamsize size = s.size();
0025 std::streamsize width = os.width();
0026 std::streamsize remainder = 0;
0027
0028 os.width(0);
0029 os << '{';
0030 if (width > 2 + (size - 1))
0031 {
0032
0033 width -= 2 + (size - 1);
0034
0035
0036 remainder = width % size;
0037 width = width / size;
0038 }
0039 else
0040 {
0041 width = 0;
0042 }
0043
0044
0045 os.width(width + remainder);
0046 if (!s.empty())
0047 {
0048 os << s[0];
0049 }
0050
0051 for (std::streamsize i = 1; i < size; ++i)
0052 {
0053 os << ',';
0054 os.width(width);
0055 os << s[i];
0056 }
0057 os << '}';
0058
0059 return os;
0060 }
0061
0062
0063 }