diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 097219bb..cf60547f 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -193,6 +193,50 @@ struct StringMaker > { } }; + +#ifdef CATCH_CPP11_OR_GREATER + /* + toString for tuples + */ +namespace TupleDetail { + template< + typename Tuple, + std::size_t N = 0, + bool = (N < std::tuple_size::value) + > + struct ElementPrinter { + static void print( const Tuple& tuple, std::ostream& os ) + { + os << ( N ? ", " : " " ) + << Catch::toString(std::get(tuple)); + ElementPrinter::print(tuple,os); + } + }; + + template< + typename Tuple, + std::size_t N + > + struct ElementPrinter { + static void print( const Tuple&, std::ostream& ) {} + }; + +} + +template +struct StringMaker> { + + static std::string convert( const std::tuple& tuple ) + { + std::ostringstream os; + os << '{'; + TupleDetail::ElementPrinter>::print( tuple, os ); + os << " }"; + return os.str(); + } +}; +#endif + namespace Detail { template std::string makeString( T const& value ) {