diff --git a/include/cppcore/conversion/enum.h b/include/cppcore/conversion/enum.h index ee082b5..d9cc0ee 100644 --- a/include/cppcore/conversion/enum.h +++ b/include/cppcore/conversion/enum.h @@ -12,7 +12,7 @@ namespace cppcore { \ namespace __impl { \ template<> \ - struct enum_value_traits \ + struct enum_value_traits \ { \ using enum_type = enum; \ using enum_value_pair_type = std::pair; \ @@ -38,7 +38,7 @@ namespace cppcore * * @tparam T_enum Enum type. */ - template + template struct enum_value_traits { using enum_type = T_enum; diff --git a/include/cppcore/conversion/enum.inl b/include/cppcore/conversion/enum.inl index 6922639..15fd2ac 100644 --- a/include/cppcore/conversion/enum.inl +++ b/include/cppcore/conversion/enum.inl @@ -8,6 +8,15 @@ namespace cppcore namespace __impl { + /* enum_value_traits */ + + template + decltype(auto) enum_value_traits::get_enum_values() + { + static const auto value = enum_value_vector_type(); + return value; + } + /* enum_conversion_traits */ template diff --git a/include/cppcore/conversion/string.inl b/include/cppcore/conversion/string.inl index 8c3f739..51e2faa 100644 --- a/include/cppcore/conversion/string.inl +++ b/include/cppcore/conversion/string.inl @@ -159,6 +159,15 @@ namespace cppcore { return std::string(v, N-1); } }; + template + struct op_to_string, char>>> + { + using value_type = T*; + + inline std::string operator()(const value_type& v) const + { return std::string(v); } + }; + template struct op_to_string().to_string(std::declval()), void())> { diff --git a/include/cppcore/misc/exception.h b/include/cppcore/misc/exception.h index e55075c..b113b7f 100644 --- a/include/cppcore/misc/exception.h +++ b/include/cppcore/misc/exception.h @@ -91,7 +91,7 @@ namespace cppcore /** * @brief Convert the exception to a string. */ - inline std::string to_string() const; + inline const std::string& to_string() const; /** * @brief Get the message of the exception as c-string. diff --git a/include/cppcore/misc/exception.inl b/include/cppcore/misc/exception.inl index 258a406..84607a9 100644 --- a/include/cppcore/misc/exception.inl +++ b/include/cppcore/misc/exception.inl @@ -53,14 +53,14 @@ namespace cppcore return os.str(); } - std::string exception::to_string() const + const std::string& exception::to_string() const { if (_msg_cache_empty) { _msg_cache = print(); _msg_cache_empty = false; } - return _msg_cache.c_str(); + return _msg_cache; } const char* exception::what() const throw()