#ifndef CTTI_NAMEOF_HPP #define CTTI_NAMEOF_HPP #include #include #include #include #include #include #include #include namespace ctti { template constexpr ctti::detail::cstring nameof(); template constexpr ctti::detail::cstring nameof(); namespace detail { template struct TypeNameLength : std::integral_constant< std::size_t, ctti::nameof().length() > {}; template struct TypeNameLength : std::integral_constant< std::size_t, ctti::nameof().length() > {}; template struct TypeNameLength::value>::type> : std::integral_constant< std::size_t, ctti::nameof().length() > {}; } template constexpr ctti::detail::cstring nameof(); namespace detail { template struct another_level_of_indirection {}; template struct nameof_impl { static constexpr ctti::detail::cstring apply() { return ctti::detail::filter_typename_prefix(ctti::pretty_function::type().pad( CTTI_TYPE_PRETTY_FUNCTION_LEFT, CTTI_TYPE_PRETTY_FUNCTION_RIGHT )); } }; template struct nameof_impl> { static constexpr ctti::detail::cstring apply() { return T::ctti_nameof(); } }; template struct nameof_impl>, void> { static constexpr ctti::detail::cstring apply() { return ctti::pretty_function::value().pad( CTTI_VALUE_PRETTY_FUNCTION_LEFT + ctti::detail::TypeNameLength::value + CTTI_VALUE_PRETTY_FUNCTION_SEPARATION, CTTI_VALUE_PRETTY_FUNCTION_RIGHT ); } }; template struct nameof_impl, void> { static constexpr ctti::detail::cstring apply() { return ctti::nameof(); } }; } template constexpr ctti::detail::cstring ctti_nameof(ctti::type_tag) { return ctti::detail::nameof_impl::apply(); } template constexpr ctti::detail::cstring ctti_nameof(ctti::static_value) { return ctti::detail::nameof_impl>>::apply(); } template constexpr ctti::detail::cstring nameof() { using namespace ctti; return ctti_nameof(ctti::type_tag()); } template constexpr ctti::detail::cstring nameof() { using namespace ctti; return ctti_nameof(ctti::static_value()); } #ifdef CTTI_HAS_VARIABLE_TEMPLATES template constexpr ctti::detail::cstring nameof_v = ctti::nameof(); // CONSIDER USING nameof_v INSTEAD template constexpr ctti::detail::cstring nameof_value_v = ctti::nameof(); #endif // CTTI_HAS_VARIABLE_TEMPLATES } namespace std { constexpr ctti::detail::cstring ctti_nameof(ctti::type_tag) { return "std::string"; } } #endif // CTTI_NAMEOF_HPP