Use std type traits instead of intrinsics

This removes warnings and mimics what has been done in Godot itself.
pull/1018/head
George Marques 2023-01-28 13:59:34 -03:00
parent a8d8485060
commit 64be8c1507
No known key found for this signature in database
GPG Key ID: 046BD46A3201E43D
1 changed files with 4 additions and 4 deletions

View File

@ -108,7 +108,7 @@ public:
template <class T> template <class T>
void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wrapped, T>>::type * = nullptr) { void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wrapped, T>>::type * = nullptr) {
if (!__has_trivial_destructor(T)) { if (!std::is_trivially_destructible<T>::value) {
p_class->~T(); p_class->~T();
} }
@ -122,7 +122,7 @@ void memdelete(T *p_class) {
template <class T, class A> template <class T, class A>
void memdelete_allocator(T *p_class) { void memdelete_allocator(T *p_class) {
if (!__has_trivial_destructor(T)) { if (!std::is_trivially_destructible<T>::value) {
p_class->~T(); p_class->~T();
} }
@ -145,7 +145,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
ERR_FAIL_COND_V(!mem, failptr); ERR_FAIL_COND_V(!mem, failptr);
*(mem - 1) = p_elements; *(mem - 1) = p_elements;
if (!__has_trivial_constructor(T)) { if (!std::is_trivially_destructible<T>::value) {
T *elems = (T *)mem; T *elems = (T *)mem;
/* call operator new */ /* call operator new */
@ -161,7 +161,7 @@ template <typename T>
void memdelete_arr(T *p_class) { void memdelete_arr(T *p_class) {
uint64_t *ptr = (uint64_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); uint64_t elem_count = *(ptr - 1);
for (uint64_t i = 0; i < elem_count; i++) { for (uint64_t i = 0; i < elem_count; i++) {