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/local_vector.h | |
parent | 55845bac260628788fde2ea431ecaad3ff26d1bc (diff) |
[Core] Use std type traits to check operations triviality.
Diffstat (limited to 'core/templates/local_vector.h')
-rw-r--r-- | core/templates/local_vector.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h index 8d687effcf..49690f2373 100644 --- a/core/templates/local_vector.h +++ b/core/templates/local_vector.h @@ -37,6 +37,7 @@ #include "core/templates/vector.h" #include <initializer_list> +#include <type_traits> // If tight, it grows strictly as much as needed. // Otherwise, it grows exponentially (the default and what you want in most cases). @@ -67,7 +68,7 @@ public: CRASH_COND_MSG(!data, "Out of memory"); } - if (!__has_trivial_constructor(T) && !force_trivial) { + if (!std::is_trivially_constructible<T>::value && !force_trivial) { memnew_placement(&data[count++], T(p_elem)); } else { data[count++] = p_elem; @@ -80,7 +81,7 @@ public: for (U i = p_index; i < count; i++) { data[i] = data[i + 1]; } - if (!__has_trivial_destructor(T) && !force_trivial) { + if (!std::is_trivially_destructible<T>::value && !force_trivial) { data[count].~T(); } } @@ -93,7 +94,7 @@ public: if (count > p_index) { data[p_index] = data[count]; } - if (!__has_trivial_destructor(T) && !force_trivial) { + if (!std::is_trivially_destructible<T>::value && !force_trivial) { data[count].~T(); } } @@ -134,7 +135,7 @@ public: _FORCE_INLINE_ U size() const { return count; } void resize(U p_size) { if (p_size < count) { - if (!__has_trivial_destructor(T) && !force_trivial) { + if (!std::is_trivially_destructible<T>::value && !force_trivial) { for (U i = p_size; i < count; i++) { data[i].~T(); } @@ -151,7 +152,7 @@ public: data = (T *)memrealloc(data, capacity * sizeof(T)); CRASH_COND_MSG(!data, "Out of memory"); } - if (!__has_trivial_constructor(T) && !force_trivial) { + if (!std::is_trivially_constructible<T>::value && !force_trivial) { for (U i = count; i < p_size; i++) { memnew_placement(&data[i], T); } |