summaryrefslogtreecommitdiffstats
path: root/core/variant
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-04-11 13:13:59 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-04-11 13:13:59 -0500
commit127025679baea9871cc09717c7e49f8af2ea9a37 (patch)
treeecdba805e255468529286148805c9b07fc1012c6 /core/variant
parentb2f425fe680d1ed5d5b5fa9ae289ae93fd294607 (diff)
downloadredot-engine-127025679baea9871cc09717c7e49f8af2ea9a37.tar.gz
Core: Use `<type_traits>` where applicable
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/type_info.h37
1 files changed, 2 insertions, 35 deletions
diff --git a/core/variant/type_info.h b/core/variant/type_info.h
index 9c52db3345..15cb6c9c1a 100644
--- a/core/variant/type_info.h
+++ b/core/variant/type_info.h
@@ -33,31 +33,7 @@
#include "core/typedefs.h"
-template <bool C, typename T = void>
-struct EnableIf {
- typedef T type;
-};
-
-template <typename T>
-struct EnableIf<false, T> {
-};
-
-template <typename, typename>
-inline constexpr bool types_are_same_v = false;
-
-template <typename T>
-inline constexpr bool types_are_same_v<T, T> = true;
-
-template <typename B, typename D>
-struct TypeInherits {
- static D *get_d();
-
- static char (&test(B *))[1];
- static char (&test(...))[2];
-
- static bool const value = sizeof(test(get_d())) == sizeof(char) &&
- !types_are_same_v<B volatile const, void volatile const>;
-};
+#include <type_traits>
namespace GodotTypeInfo {
enum Metadata {
@@ -223,16 +199,7 @@ MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::PACKED_STRING_ARRAY)
template <typename T>
-struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
- static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
- static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
- static inline PropertyInfo get_class_info() {
- return PropertyInfo(StringName(T::get_class_static()));
- }
-};
-
-template <typename T>
-struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
+struct GetTypeInfo<T *, std::enable_if_t<std::is_base_of_v<Object, T>>> {
static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE;
static inline PropertyInfo get_class_info() {