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/templates/cowdata.h | |
parent | 55845bac260628788fde2ea431ecaad3ff26d1bc (diff) |
[Core] Use std type traits to check operations triviality.
Diffstat (limited to 'core/templates/cowdata.h')
-rw-r--r-- | core/templates/cowdata.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index e760fc2176..0653aa76a8 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -36,6 +36,7 @@ #include "core/templates/safe_refcount.h" #include <string.h> +#include <type_traits> template <class T> class Vector; @@ -204,7 +205,7 @@ void CowData<T>::_unref(void *p_data) { } // clean up - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible<T>::value) { uint32_t *count = _get_size(); T *data = (T *)(count + 1); @@ -239,7 +240,7 @@ uint32_t CowData<T>::_copy_on_write() { T *_data = (T *)(mem_new); // initialize new elements - if (__has_trivial_copy(T)) { + if (std::is_trivially_copyable<T>::value) { memcpy(mem_new, _ptr, current_size * sizeof(T)); } else { @@ -302,7 +303,7 @@ Error CowData<T>::resize(int p_size) { // construct the newly created elements - if (!__has_trivial_constructor(T)) { + if (!std::is_trivially_constructible<T>::value) { for (int i = *_get_size(); i < p_size; i++) { memnew_placement(&_ptr[i], T); } @@ -311,7 +312,7 @@ Error CowData<T>::resize(int p_size) { *_get_size() = p_size; } else if (p_size < current_size) { - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible<T>::value) { // deinitialize no longer needed elements for (uint32_t i = p_size; i < *_get_size(); i++) { T *t = &_ptr[i]; |