diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index cf60547f..8cc02ad9 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -237,6 +237,20 @@ struct StringMaker> { }; #endif +template +struct StringMaker > { + static std::string convert( const std::pair& pair ) { + std::ostringstream oss; + oss << "{ " + << Catch::toString( pair.first ) + << ", " + << Catch::toString( pair.second ) + << " }"; + return oss.str(); + } +}; + + namespace Detail { template std::string makeString( T const& value ) { @@ -244,6 +258,7 @@ namespace Detail { } } // end namespace Detail + /// \brief converts any type to a string /// /// The default template forwards on to ostringstream - except when an diff --git a/projects/SelfTest/ToStringPair.cpp b/projects/SelfTest/ToStringPair.cpp index 2de4a55a..355cf1d1 100644 --- a/projects/SelfTest/ToStringPair.cpp +++ b/projects/SelfTest/ToStringPair.cpp @@ -1,23 +1,5 @@ #include "catch.hpp" -// === Pair === -namespace Catch { - // Note: If we put this in the right place in catch_tostring, then - // we can make it an overload of Catch::toString - template - struct StringMaker > { - static std::string convert( const std::pair& pair ) { - std::ostringstream oss; - oss << "{ " - << toString( pair.first ) - << ", " - << toString( pair.second ) - << " }"; - return oss.str(); - } - }; -} - TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { std::pair value( 34, "xyzzy" ); diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index a1676570..74e473dd 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -17,18 +17,6 @@ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" #endif -namespace Catch -{ - template<> - std::string toString >( const std::pair& value ) - { - std::ostringstream oss; - oss << "std::pair( " << value.first << ", " << value.second << " )"; - return oss.str(); - - } -} - /////////////////////////////////////////////////////////////////////////////// TEST_CASE (