mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
[Core] Use std type traits to check operations triviality.
This commit is contained in:
parent
55845bac26
commit
6f02183f8c
4 changed files with 23 additions and 18 deletions
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue