include/cppunit/TestAssert.h | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
New commits: commit 9e22a4f7c7794ab1cbd808058c13356f38ed632a Author: Markus Mohrhard <[email protected]> Date: Wed Dec 14 17:23:38 2016 +0100 simpler implementation for the enum class work around diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index 89f9209..d9f7299 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -23,29 +23,25 @@ namespace impl { // work around to handle C++11 enum class correctly. We need an own conversion to std::string // as there is no implicit coversion to int for enum class. -template<typename T, typename Enable = void> -struct toString + +template<typename T> +typename std::enable_if<!std::is_enum<T>::value, std::string>::type toStringImpl(const T& x) { - static std::string toStringImpl(const T& x) - { - OStringStream ost; - ost << x; + OStringStream ost; + ost << x; - return ost.str(); - } -}; + return ost.str(); +} template<typename T> -struct toString<T, typename std::enable_if<std::is_enum<T>::value >::type> +typename std::enable_if<std::is_enum<T>::value, std::string>::type toStringImpl(const T& x) { - static std::string toStringImpl(const T& x) - { - OStringStream ost; - ost << static_cast<typename std::underlying_type<T>::type>(x); + OStringStream ost; + ost << static_cast<typename std::underlying_type<T>::type>(x); + + return ost.str(); +} - return ost.str(); - } -}; } @@ -102,7 +98,7 @@ struct assertion_traits static std::string toString( const T& x ) { - return impl::toString<T>::toStringImpl(x); + return impl::toStringImpl(x); } }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
