1 #ifndef MEDUSA_BITS_UTILS_PRINT_HPP_
2 #define MEDUSA_BITS_UTILS_PRINT_HPP_
19 template<
class T,
class U>
20 std::ostream&
operator<<(std::ostream& xx,
const std::pair<T, U>& par) {
21 return xx <<
"(" << par.first <<
"," << par.second <<
")";
25 template<
class T,
size_t N>
26 std::ostream&
operator<<(std::ostream& xx,
const std::array<T, N>& arr) {
28 for (
size_t i = 0; i < N; ++i) {
30 if (i < N - 1) xx <<
", ";
37 template<
class T,
class A>
38 std::ostream&
operator<<(std::ostream& xx,
const std::vector<T, A>& arr) {
41 for (
size_t i = 0; i < arr.size(); ++i) {
43 if (i < arr.size() - 1) xx <<
", ";
50 template<
class T,
class A>
51 std::ostream&
operator<<(std::ostream& xx,
const std::vector<std::vector<T, A>>& arr) {
53 for (
size_t i = 0; i < arr.size(); ++i) {
54 for (
size_t j = 0; j < arr[i].size(); ++j) {
56 if (j < arr[i].size() - 1) xx <<
", ";
58 if (i < arr.size() - 1) xx <<
"; ";
65 namespace tuple_print_internal {
66 template <
class Tuple, std::
size_t N>
68 static void print(std::ostream& os,
const Tuple& t) {
69 TuplePrinter<Tuple, N - 1>::print(os, t);
70 os <<
", " << std::get<N - 1>(t);
74 template <
class Tuple>
75 struct TuplePrinter<Tuple, 1> {
76 static void print(std::ostream& os,
const Tuple& t) {
81 template <
class Tuple>
82 struct TuplePrinter<Tuple, 0> {
static void print(std::ostream&,
const Tuple&) {} };
88 template <
class... Args>
89 std::ostream&
operator<<(std::ostream& os,
const std::tuple<Args...>& t) {
91 tuple_print_internal::TuplePrinter<decltype(t),
sizeof...(Args)>::print(os, t);
98 #endif // MEDUSA_BITS_UTILS_PRINT_HPP_