32 namespace xerus {
namespace misc {
35 template<
size_t n = 0,
typename... Tp,
typename std::enable_if<n+1 ==
sizeof...(Tp),
int>::type = 0>
36 inline void print(std::ostream& _out,
const std::tuple<Tp...>& t) {
37 _out << std::get<n>(t);
40 template<
size_t n = 0,
typename... Tp,
typename std::enable_if<n+1 <
sizeof...(Tp),
int>::type = 0>
41 inline void print(std::ostream& _out,
const std::tuple<Tp...>& t) {
42 _out << std::get<n>(t) <<
", ";
43 print<n + 1, Tp...>(_out, t);
50 std::ostream&
operator<<(std::ostream& _out,
const std::tuple<Tp...>& _tuple) {
59 template<
class first_t,
class second_t>
60 std::ostream& operator<<(std::ostream& _out, const std::pair<first_t, second_t>& _pair) {
61 _out <<
"[ " << _pair.first <<
" | " << _pair.second <<
" ]";
67 template<
class item_t,
class... rest_t>
68 std::ostream&
operator<<(std::ostream& _out,
const std::vector<item_t, rest_t...>& _container) {
69 if(_container.size() == 0) { _out <<
"{ }";
return _out; }
71 for(
const item_t& item : _container) { _out << item <<
", "; }
78 template<
class item_t,
class... rest_t>
79 std::ostream&
operator<<(std::ostream& _out,
const std::set<item_t, rest_t...>& _container) {
80 if(_container.size() == 0) { _out <<
"{ }";
return _out; }
82 for(
const item_t& item : _container) { _out << item <<
", "; }
89 template<
class T,
class U>
90 std::ostream& operator<<(std::ostream& _out, const std::map<T,U>& _set) {
91 if(_set.size() == 0) { _out <<
"{ }";
return _out; }
93 for(
const auto& item : _set) { _out <<
"(" << item.first <<
", " << item.second <<
"), "; }
The main namespace of xerus.
void print(std::ostream &_out, const std::tuple< Tp... > &t)
std::ostream & operator<<(std::ostream &_out, const std::tuple< Tp... > &_tuple)
Allow to pipe tuples to ostreams.