clboss/Util/stream_elements.hpp
Ken Sedgwick 56f405f063 Improve the ConstructedListpeers handling diagnostics
Hopefully this pattern will prove useful in future debugging
improvements.
2024-07-16 16:01:56 -07:00

27 lines
499 B
C++

#ifndef UTIL_STREAM_ELEMENTS_HPP
#define UTIL_STREAM_ELEMENTS_HPP
#include<sstream>
#include<string>
namespace Util {
template<typename Container>
std::ostream& stream_elements(std::ostream& os, Container const& v) {
os << "[";
auto it = std::begin(v);
auto end = std::end(v);
if (it != end) {
os << *it;
++it;
}
for (; it != end; ++it) {
os << ", " << *it;
}
os << "]";
return os;
}
}
#endif /* !defined(UTIL_STREAM_ELEMENTS_HPP) */