summaryrefslogtreecommitdiffstats
path: root/core/variant
diff options
context:
space:
mode:
authorvittorioromeo <mail@vittorioromeo.com>2024-02-02 15:43:21 +0100
committervittorioromeo <mail@vittorioromeo.com>2024-02-02 15:43:21 +0100
commit55ed34e37c61ae53e676f73a2e4444d7ecb4ce7d (patch)
treea65f7e697634149faa5ff8f5b7edccbb32ba06bc /core/variant
parent10e111477db68fe65776a1d68fb1ffccaf6520fc (diff)
downloadredot-engine-55ed34e37c61ae53e676f73a2e4444d7ecb4ce7d.tar.gz
Use '_v' shorthand for type traits and 'if constexpr' where appropriate
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/binder_common.h8
-rw-r--r--core/variant/type_info.h12
2 files changed, 8 insertions, 12 deletions
diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h
index c9f5ae7fc6..a44b938395 100644
--- a/core/variant/binder_common.h
+++ b/core/variant/binder_common.h
@@ -51,7 +51,7 @@ template <class T>
struct VariantCaster {
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
using TStripped = std::remove_pointer_t<T>;
- if constexpr (std::is_base_of<Object, TStripped>::value) {
+ if constexpr (std::is_base_of_v<Object, TStripped>) {
return Object::cast_to<TStripped>(p_variant);
} else {
return p_variant;
@@ -63,7 +63,7 @@ template <class T>
struct VariantCaster<T &> {
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
using TStripped = std::remove_pointer_t<T>;
- if constexpr (std::is_base_of<Object, TStripped>::value) {
+ if constexpr (std::is_base_of_v<Object, TStripped>) {
return Object::cast_to<TStripped>(p_variant);
} else {
return p_variant;
@@ -75,7 +75,7 @@ template <class T>
struct VariantCaster<const T &> {
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
using TStripped = std::remove_pointer_t<T>;
- if constexpr (std::is_base_of<Object, TStripped>::value) {
+ if constexpr (std::is_base_of_v<Object, TStripped>) {
return Object::cast_to<TStripped>(p_variant);
} else {
return p_variant;
@@ -226,7 +226,7 @@ template <typename T>
struct VariantObjectClassChecker {
static _FORCE_INLINE_ bool check(const Variant &p_variant) {
using TStripped = std::remove_pointer_t<T>;
- if constexpr (std::is_base_of<Object, TStripped>::value) {
+ if constexpr (std::is_base_of_v<Object, TStripped>) {
Object *obj = p_variant;
return Object::cast_to<TStripped>(p_variant) || !obj;
} else {
diff --git a/core/variant/type_info.h b/core/variant/type_info.h
index c1f2f86a96..49c4db8229 100644
--- a/core/variant/type_info.h
+++ b/core/variant/type_info.h
@@ -43,14 +43,10 @@ struct EnableIf<false, T> {
};
template <typename, typename>
-struct TypesAreSame {
- static bool const value = false;
-};
+inline constexpr bool types_are_same_v = false;
-template <typename A>
-struct TypesAreSame<A, A> {
- static bool const value = true;
-};
+template <typename T>
+inline constexpr bool types_are_same_v<T, T> = true;
template <typename B, typename D>
struct TypeInherits {
@@ -60,7 +56,7 @@ struct TypeInherits {
static char (&test(...))[2];
static bool const value = sizeof(test(get_d())) == sizeof(char) &&
- !TypesAreSame<B volatile const, void volatile const>::value;
+ !types_are_same_v<B volatile const, void volatile const>;
};
namespace GodotTypeInfo {