1 // Copyright 2018-2019 Hans Dembinski
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #ifndef BOOST_HISTOGRAM_TEST_STD_OSTREAM_HPP
8 #define BOOST_HISTOGRAM_TEST_STD_OSTREAM_HPP
9
10 #include <boost/mp11/tuple.hpp>
11 #include <ostream>
12 #include <utility>
13 #include <vector>
14
15 namespace std {
16 // never add to std, we only do it here to get ADL working :(
17 template <class T>
operator <<(ostream & os,const vector<T> & v)18 ostream& operator<<(ostream& os, const vector<T>& v) {
19 os << "[ ";
20 for (const auto& x : v) os << x << " ";
21 os << "]";
22 return os;
23 }
24
25 template <class... Ts>
operator <<(ostream & os,const std::tuple<Ts...> & t)26 ostream& operator<<(ostream& os, const std::tuple<Ts...>& t) {
27 os << "[ ";
28 ::boost::mp11::tuple_for_each(t, [&os](const auto& x) { os << x << " "; });
29 os << "]";
30 return os;
31 }
32
33 template <class T, class U>
operator <<(ostream & os,const std::pair<T,U> & t)34 ostream& operator<<(ostream& os, const std::pair<T, U>& t) {
35 os << "[ " << t.first << " " << t.second << " ]";
36 return os;
37 }
38 } // namespace std
39
40 #endif
41