diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-01-07 22:38:21 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-01-07 22:38:21 +0100 |
commit | a53e4a57565d3375a978effbbc32d3eed6aac7e3 (patch) | |
tree | 070e7bd084fde9b62769c7ad1e4dbb52e82a10d9 /src/common/Utilities/Util.h | |
parent | 7830e5a7a1b93b0cd083baa3b70a0cfeb475f5f5 (diff) |
Core/Misc: Replace enable_if overload selection with if constexpr
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r-- | src/common/Utilities/Util.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index caf8dd88bb1..57523ca558f 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -485,11 +485,24 @@ Ret* Coalesce(T1* first, T*... rest) return static_cast<Ret*>(first); } -TC_COMMON_API std::string GetTypeName(std::type_info const&); +namespace Trinity +{ +namespace Impl +{ + TC_COMMON_API std::string GetTypeName(std::type_info const&); +} + template <typename T> -std::string GetTypeName() { return GetTypeName(typeid(T)); } +std::string GetTypeName() { return Impl::GetTypeName(typeid(T)); } template <typename T> -std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::type_info>, std::string> GetTypeName(T&& v) { return GetTypeName(typeid(v)); } +std::string GetTypeName(T&& v) +{ + if constexpr (std::is_same_v<std::remove_cv_t<T>, std::type_info>) + return Impl::GetTypeName(v); + else + return Impl::GetTypeName(typeid(v)); +} +} template<typename T> struct NonDefaultConstructible |