@@ -36,23 +36,39 @@ template <auto Value>
3636CONSTEVAL static auto enum_as_string () -> std::basic_string_view<char> {
3737#ifdef __clang__
3838 constexpr std::string_view value_string = __PRETTY_FUNCTION__;
39- constexpr auto rhs = value_string.size () - 2 ;
4039#elif defined(__GNUC__) || defined(__GNUG__)
4140 constexpr std::string_view value_string = __PRETTY_FUNCTION__;
42- constexpr auto rhs = value_string.size () - 2 ;
4341#else
4442 static_assert (always_false_v<Tag>,
4543 " Unknown compiler, can't build type name." );
4644#endif
45+ constexpr auto qual_str = [&]() -> std::string_view {
46+ constexpr auto rhs = value_string.size () - 2 ;
47+ if (auto const eq_pos = value_string.find_last_of (' =' );
48+ eq_pos != std::string_view::npos) {
49+ auto const lhs = eq_pos + 2 ;
50+ return value_string.substr (lhs, rhs - lhs + 1 );
51+ }
52+ return value_string;
53+ }();
54+
55+ constexpr auto cast_str = [&]() -> std::string_view {
56+ if (auto const close_paren_pos = qual_str.find_last_of (' )' );
57+ close_paren_pos != std::string_view::npos) {
58+ if (qual_str[close_paren_pos + 1 ] != ' :' ) {
59+ return qual_str;
60+ }
61+ }
4762
48- constexpr auto lhs = [&]() -> std::string_view::size_type {
49- if (auto const colon_pos = value_string.find_last_of (' :' );
63+ if (auto const colon_pos = qual_str.find_last_of (' :' );
5064 colon_pos != std::string_view::npos) {
51- return colon_pos + 1 ;
65+ return qual_str. substr ( colon_pos + 1 ) ;
5266 }
53- return 0 ;
67+
68+ return qual_str;
5469 }();
55- return value_string.substr (lhs, rhs - lhs + 1 );
70+
71+ return cast_str;
5672}
5773} // namespace v1
5874} // namespace stdx
0 commit comments