summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp
diff options
context:
space:
mode:
authorAdam Scott <ascott.ca@gmail.com>2023-08-15 11:51:34 -0400
committerAdam Scott <ascott.ca@gmail.com>2023-08-15 18:50:47 -0400
commit5c262844adb083fcaa9ef64b650fb9968d4812fd (patch)
treed70b0199a15d0db3503cb700dea78bc3d8e3b33d /include/godot_cpp
parentdf5500565a2fd18e7a505ac09c1230dc7b3b6b9d (diff)
downloadredot-cpp-5c262844adb083fcaa9ef64b650fb9968d4812fd.tar.gz
Fix Clang deprecated builtins
It seems that Clang and GCC have different interpretations of certain builtins. So this PR uses std <type_traits> functions just as cowdata.h does in the godot project.
Diffstat (limited to 'include/godot_cpp')
-rw-r--r--include/godot_cpp/templates/cowdata.hpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/godot_cpp/templates/cowdata.hpp b/include/godot_cpp/templates/cowdata.hpp
index 18320d8..ee3f5a4 100644
--- a/include/godot_cpp/templates/cowdata.hpp
+++ b/include/godot_cpp/templates/cowdata.hpp
@@ -39,6 +39,7 @@
#include <cstring>
#include <new>
+#include <type_traits>
namespace godot {
@@ -210,9 +211,9 @@ void CowData<T>::_unref(void *p_data) {
if (refc->decrement() > 0) {
return; // still in use
}
- // clean up
- if (!__has_trivial_destructor(T)) {
+ // clean up
+ if (std::is_trivially_destructible<T>::value) {
uint32_t *count = _get_size();
T *data = (T *)(count + 1);
@@ -247,7 +248,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 {
@@ -310,7 +311,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) {
T *elems = _get_data();
for (int i = *_get_size(); i < p_size; i++) {
@@ -321,7 +322,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 = &_get_data()[i];