From 29b056b056caa5ce70ffeb98501ffa6ed1c4c830 Mon Sep 17 00:00:00 2001 From: Markus Blatt <mblatt@dune-project.org> Date: Tue, 1 Sep 2009 12:16:13 +0000 Subject: [PATCH] Stripped superfluous comma. Made tuple_writer available and added a delimiter argument. [[Imported from SVN: r5570]] --- common/tuples.hh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/tuples.hh b/common/tuples.hh index c9bce4e80..4692b3d69 100644 --- a/common/tuples.hh +++ b/common/tuples.hh @@ -602,14 +602,24 @@ namespace Dune { using std::tr1::make_tuple; #endif -#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE + template<int i> struct tuple_writer { template<class T> - static std::ostream& put(std::ostream& os, const T& t) + static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") + { + return tuple_writer<i-1>::put(os,t,delim)<<delim<<get<i-1>(t); + } + }; + + template<> + struct tuple_writer<1> + { + template<class T> + static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") { - return tuple_writer<i-1>::put(os,t)<<", "<<get<i-1>(t); + return os<<get<0>(t); } }; @@ -617,12 +627,13 @@ namespace Dune { struct tuple_writer<0> { template<class T> - static std::ostream& put(std::ostream& os, const T& t) + static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") { return os; } }; +#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE /** * \brief Print a tuple. */ -- GitLab