TODO: constexpr nameoftype
This commit is contained in:
parent
654c74d5db
commit
8c4d52963a
2 changed files with 4 additions and 3 deletions
|
@ -208,7 +208,7 @@ template <typename T,
|
||||||
inline NAMEOF_CONSTEXPR14 detail::cstring Nameof(T&&, const char*, std::size_t, bool) = delete;
|
inline NAMEOF_CONSTEXPR14 detail::cstring Nameof(T&&, const char*, std::size_t, bool) = delete;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline constexpr detail::cstring NameofTypeRaw() noexcept {
|
inline detail::cstring NameofTypeRaw() noexcept {
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
return {__PRETTY_FUNCTION__ + (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1),
|
return {__PRETTY_FUNCTION__ + (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1),
|
||||||
(sizeof(__PRETTY_FUNCTION__) - 1) - (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1) - (sizeof("]") - 1)};
|
(sizeof(__PRETTY_FUNCTION__) - 1) - (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1) - (sizeof("]") - 1)};
|
||||||
|
@ -224,7 +224,7 @@ inline constexpr detail::cstring NameofTypeRaw() noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename D = typename detail::Decay<T>::type>
|
template <typename T, typename D = typename detail::Decay<T>::type>
|
||||||
inline NAMEOF_CONSTEXPR14 detail::cstring NameofType() noexcept {
|
inline detail::cstring NameofType() noexcept {
|
||||||
const auto raw_type_name = NameofTypeRaw<D>();
|
const auto raw_type_name = NameofTypeRaw<D>();
|
||||||
return detail::NameofBase(raw_type_name.begin(), raw_type_name.length(), false);
|
return detail::NameofBase(raw_type_name.begin(), raw_type_name.length(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ TEST_CASE("constexpr") {
|
||||||
constexpr auto cx6 = NAMEOF_RAW(__cplusplus);
|
constexpr auto cx6 = NAMEOF_RAW(__cplusplus);
|
||||||
static_assert(cx6 == "__cplusplus", "");
|
static_assert(cx6 == "__cplusplus", "");
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
SECTION("NAMEOF_TYPE") {
|
SECTION("NAMEOF_TYPE") {
|
||||||
SomeClass<int> a;
|
SomeClass<int> a;
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ TEST_CASE("constexpr") {
|
||||||
static_assert(cx3 == "SomeClass<int>", "");
|
static_assert(cx3 == "SomeClass<int>", "");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue