1 #ifndef UTOPIA_CORE_OSTREAM_HH
2 #define UTOPIA_CORE_OSTREAM_HH
16 template <
typename T,
typename U >
18 operator<<(std::ostream& out,
const std::pair< T, U >& pair)
20 out <<
"(" << pair.first <<
", " << pair.second <<
")";
33 std::enable_if_t< is_container_v< T >, std::ostream& >
34 operator<<(std::ostream& out,
const T& container)
36 if (container.size() == 0)
42 out << std::setprecision(16) <<
"[";
44 for (
auto it = container.begin();
45 it != std::next(
std::begin(container), container.size() - 1);
51 out << *std::next(
std::begin(container), container.size() - 1) <<
"]";
67 operator<<(std::ostream& out,
const std::vector< bool >& container)
69 if (container.size() == 0)
71 out <<
"[]" << std::endl;
76 for (std::size_t i = 0; i < container.size() - 1; ++i)
78 out << container[i] <<
", ";
80 out << container.back() <<
"]";
98 template <
template <
typename,
typename,
typename... >
class MapType,
103 is_associative_container_v< MapType< Key, Value, Args... > > or
104 is_unordered_associative_container_v< MapType< Key, Value, Args... > >,
106 operator<<(std::ostream& out, const MapType< Key, Value, Args... >& map)
115 for (auto it = map.begin();
116 it != std::next(map.begin(), map.size() - 1);
121 out << *std::next(map.begin(), map.size() - 1) << "]";
133 template < typename... Types >
135 operator<<(std::ostream& ostr, std::tuple< Types... > tuple)
137 std::string val_str("(");
139 auto report_val = [&val_str](auto&& val) {
140 val_str += std::to_string(val) + ", ";
142 boost::hana::for_each(tuple, report_val);
145 val_str.erase(val_str.end() - 2);
162 template < typename T >
Definition: metaprogramming.hh:43
std::ostream & operator<<(std::ostream &out, const std::pair< T, U > &pair)
pretty print a pair
Definition: ostream.hh:18
Definition: parallel.hh:235