diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-08-04 13:53:03 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-08-04 14:05:17 +0200 |
commit | 6f02183f8c99694ca80bbd93234cf3fc338cd54e (patch) | |
tree | f3fa970f72a9e3332aa9aefd1b5cbe45602231f3 /core/os | |
parent | 55845bac260628788fde2ea431ecaad3ff26d1bc (diff) |
[Core] Use std type traits to check operations triviality.
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/memory.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/os/memory.h b/core/os/memory.h index 42ba9634e2..0e1afe027e 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -36,6 +36,7 @@ #include <stddef.h> #include <new> +#include <type_traits> #ifndef PAD_ALIGN #define PAD_ALIGN 16 //must always be greater than this at much @@ -104,7 +105,7 @@ void memdelete(T *p_class) { if (!predelete_handler(p_class)) { return; // doesn't want to be deleted } - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible<T>::value) { p_class->~T(); } @@ -116,7 +117,7 @@ void memdelete_allocator(T *p_class) { if (!predelete_handler(p_class)) { return; // doesn't want to be deleted } - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible<T>::value) { p_class->~T(); } @@ -146,7 +147,7 @@ T *memnew_arr_template(size_t p_elements) { ERR_FAIL_COND_V(!mem, failptr); *(mem - 1) = p_elements; - if (!__has_trivial_constructor(T)) { + if (!std::is_trivially_constructible<T>::value) { T *elems = (T *)mem; /* call operator new */ @@ -173,7 +174,7 @@ template <typename T> void memdelete_arr(T *p_class) { uint64_t *ptr = (uint64_t *)p_class; - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible<T>::value) { uint64_t elem_count = *(ptr - 1); for (uint64_t i = 0; i < elem_count; i++) { |