From 7367e4d50af1729d8e809a813f0dd5e8b45640e5 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Thu, 25 Jul 2013 15:15:12 +0200 Subject: [PATCH] utility : add printing of a tuple - << tuple now works, with a default version. Useful for debugging --- triqs/utility/tuple_tools.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/triqs/utility/tuple_tools.hpp b/triqs/utility/tuple_tools.hpp index 83c37a2d..538cbd07 100644 --- a/triqs/utility/tuple_tools.hpp +++ b/triqs/utility/tuple_tools.hpp @@ -183,6 +183,26 @@ namespace triqs { namespace tuple { template auto fold_on_zip (F && f,T1 const & t1, T2 const & t2, R && r) DECL_AND_RETURN( fold_on_zip_impl::value-1,T1,T2>()(std::forward(f),t1,t2,std::forward(r))); + /* + * print a tuple + */ + template struct __s {}; + template void print_tuple_impl (std::ostream& os, T const& t, std::integral_constant ) {} + template void print_tuple_impl (std::ostream& os, T const& t, std::integral_constant ) { + os << std::get(t); + if (rpos>0) os << ','; + print_tuple_impl(os, t, std::integral_constant()); + } }} + +namespace std { + template std::ostream & operator << (std::ostream & os, std::tuple const & t) { + os << "("; + constexpr int L = sizeof...(T); + triqs::tuple::print_tuple_impl(os,t,std::integral_constant()); + return os << ")"; + } +} + #endif