4 #ifndef LEXY_DETAIL_TYPE_NAME_HPP_INCLUDED
5 #define LEXY_DETAIL_TYPE_NAME_HPP_INCLUDED
22 #if defined(__clang__)
23 # define LEXY_HAS_AUTOMATIC_TYPE_NAME 1
24 # define LEXY_HAS_CONSTEXPR_AUTOMATIC_TYPE_NAME 1
26 constexpr
auto prefix =
string_view(
"auto lexy::_detail::_full_type_name() [T = ");
30 function.remove_prefix(prefix.length());
31 function.remove_suffix(suffix.length());
34 #elif defined(__GNUC__)
35 # define LEXY_HAS_AUTOMATIC_TYPE_NAME 1
37 # define LEXY_HAS_CONSTEXPR_AUTOMATIC_TYPE_NAME 1
39 # define LEXY_HAS_CONSTEXPR_AUTOMATIC_TYPE_NAME 0
43 =
string_view(
"constexpr auto lexy::_detail::_full_type_name() [with T = ");
47 function.remove_prefix(prefix.length());
48 function.remove_suffix(suffix.length());
51 #elif defined(_MSC_VER)
52 # define LEXY_HAS_AUTOMATIC_TYPE_NAME 1
53 # define LEXY_HAS_CONSTEXPR_AUTOMATIC_TYPE_NAME 1
55 constexpr
auto prefix =
string_view(
"auto __cdecl lexy::_detail::_full_type_name<");
59 function.remove_prefix(prefix.length());
60 function.remove_suffix(suffix.length());
62 if (
auto s =
string_view(
"struct ");
function.starts_with(s))
63 function.remove_prefix(s.length());
64 else if (
auto c =
string_view(
"class ");
function.starts_with(c))
65 function.remove_prefix(c.length());
70 # define LEXY_HAS_AUTOMATIC_TYPE_NAME 0
71 # define LEXY_HAS_CONSTEXPR_AUTOMATIC_TYPE_NAME 0
78 template <
typename T,
int NsCount>
81 auto name = _full_type_name<T>();
85 for (
auto namespace_count = NsCount; namespace_count > 0; --namespace_count)
87 auto pos = name.find(
"::");
90 name.remove_prefix(pos + 2);
95 template <
typename T,
int NsCount = 1>
98 if constexpr (_detail::is_detected<_detect_name_f, T>)
100 else if constexpr (_detail::is_detected<_detect_name_v, T>)
103 return make_cstr<_type_name<T, NsCount>>;
105 return "unknown-type";
108 template <
typename T,
int NsCount>
113 template <
typename T,
int NsCount = 1>
116 if constexpr (_detail::is_detected<_detect_name_v, T>
117 && !_detail::is_detected<_detect_name_f, T>)
126 return &_type_id_holder<T, NsCount>;
131 #endif // LEXY_DETAIL_TYPE_NAME_HPP_INCLUDED