diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index e8e38296..dbb31423 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -22,6 +22,11 @@ #endif namespace Catch { + +// Why we're here. +template +std::string toString( T const& value ); + namespace Detail { // SFINAE is currently disabled by default for all compilers. @@ -64,10 +69,38 @@ namespace Detail { #endif +#if defined(CATCH_CPP11_OR_GREATER) + template::value + > + struct EnumStringMaker + { + static std::string convert( T const& ) { return "{?}"; } + }; + + template + struct EnumStringMaker + { + static std::string convert( T const& v ) + { + return ::Catch::toString( + static_cast::type>(v) + ); + } + }; +#endif template struct StringMakerBase { +#if defined(CATCH_CPP11_OR_GREATER) + template + static std::string convert( T const& v ) + { + return EnumStringMaker::convert( v ); + } +#else template static std::string convert( T const& ) { return "{?}"; } +#endif }; template<> @@ -89,9 +122,6 @@ namespace Detail { } // end namespace Detail -template -std::string toString( T const& value ); - template struct StringMaker : Detail::StringMakerBase::value> {};