Skip to content

Commit 1a49895

Browse files
committed
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.
1 parent df55005 commit 1a49895

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

include/godot_cpp/templates/cowdata.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include <cstring>
4141
#include <new>
42+
#include <type_traits>
4243

4344
namespace godot {
4445

@@ -210,9 +211,9 @@ void CowData<T>::_unref(void *p_data) {
210211
if (refc->decrement() > 0) {
211212
return; // still in use
212213
}
213-
// clean up
214214

215-
if (!__has_trivial_destructor(T)) {
215+
// clean up
216+
if (std::is_trivially_destructible<T>()) {
216217
uint32_t *count = _get_size();
217218
T *data = (T *)(count + 1);
218219

@@ -247,7 +248,7 @@ uint32_t CowData<T>::_copy_on_write() {
247248
T *_data = (T *)(mem_new);
248249

249250
// initialize new elements
250-
if (__has_trivial_copy(T)) {
251+
if (std::is_trivially_copyable<T>::value) {
251252
memcpy(mem_new, _ptr, current_size * sizeof(T));
252253

253254
} else {
@@ -310,7 +311,7 @@ Error CowData<T>::resize(int p_size) {
310311

311312
// construct the newly created elements
312313

313-
if (!__has_trivial_constructor(T)) {
314+
if (!std::is_trivially_constructible<T>::value) {
314315
T *elems = _get_data();
315316

316317
for (int i = *_get_size(); i < p_size; i++) {
@@ -321,7 +322,7 @@ Error CowData<T>::resize(int p_size) {
321322
*_get_size() = p_size;
322323

323324
} else if (p_size < current_size) {
324-
if (!__has_trivial_destructor(T)) {
325+
if (!std::is_trivially_destructible<T>::value) {
325326
// deinitialize no longer needed elements
326327
for (uint32_t i = p_size; i < *_get_size(); i++) {
327328
T *t = &_get_data()[i];

0 commit comments

Comments
 (0)