feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef A_HASH_MAP_H
#define A_HASH_MAP_H
#pragma once
#include "core/templates/hash_map.h"
@ -666,7 +665,9 @@ public:
}
AHashMap(const HashMap<TKey, TValue> &p_other) {
reserve(p_other.size());
if (p_other.size() > get_capacity()) {
reserve(p_other.size());
}
for (const KeyValue<TKey, TValue> &E : p_other) {
uint32_t hash = _hash(E.key);
_insert_element(E.key, E.value, hash);
@ -704,7 +705,9 @@ public:
}
AHashMap(std::initializer_list<KeyValue<TKey, TValue>> p_init) {
reserve(p_init.size());
if (p_init.size() > get_capacity()) {
reserve(p_init.size());
}
for (const KeyValue<TKey, TValue> &E : p_init) {
insert(E.key, E.value);
}
@ -736,5 +739,3 @@ extern template class AHashMap<String, int>;
extern template class AHashMap<StringName, StringName>;
extern template class AHashMap<StringName, Variant>;
extern template class AHashMap<StringName, int>;
#endif // A_HASH_MAP_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef BIN_SORTED_ARRAY_H
#define BIN_SORTED_ARRAY_H
#pragma once
#include "core/templates/local_vector.h"
#include "core/templates/paged_array.h"
@ -177,5 +176,3 @@ public:
reset();
}
};
#endif // BIN_SORTED_ARRAY_H

View file

@ -0,0 +1,73 @@
/**************************************************************************/
/* bit_field.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#pragma once
#include "core/typedefs.h"
#include <type_traits>
// TODO: Replace `typename` with enum concept once C++20 concepts/constraints are allowed.
template <typename T>
class BitField {
static_assert(std::is_enum_v<T>);
uint64_t value;
public:
_ALWAYS_INLINE_ constexpr void set_flag(BitField p_flag) { value |= p_flag.value; }
_ALWAYS_INLINE_ constexpr bool has_flag(BitField p_flag) const { return value & p_flag.value; }
_ALWAYS_INLINE_ constexpr bool is_empty() const { return value == 0; }
_ALWAYS_INLINE_ constexpr void clear_flag(BitField p_flag) { value &= ~p_flag.value; }
_ALWAYS_INLINE_ constexpr void clear() { value = 0; }
[[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_combined(BitField p_other) const { return BitField(value | p_other.value); }
[[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_shared(BitField p_other) const { return BitField(value & p_other.value); }
[[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_different(BitField p_other) const { return BitField(value ^ p_other.value); }
_ALWAYS_INLINE_ constexpr BitField() = default;
_ALWAYS_INLINE_ constexpr BitField(T p_value) :
value(static_cast<uint64_t>(p_value)) {}
_ALWAYS_INLINE_ constexpr operator T() const { return static_cast<T>(value); }
// TODO: Unify as single constructor once C++20 `explicit` conditionals are allowed.
template <typename V, std::enable_if_t<std::is_arithmetic_v<V> && std::is_convertible_v<T, int>, int> = 0>
_ALWAYS_INLINE_ constexpr BitField(V p_value) :
value(static_cast<uint64_t>(p_value)) {}
template <typename V, std::enable_if_t<std::is_arithmetic_v<V> && !std::is_convertible_v<T, int>, int> = 0>
_ALWAYS_INLINE_ constexpr explicit BitField(V p_value) :
value(static_cast<uint64_t>(p_value)) {}
template <typename V, std::enable_if_t<std::is_arithmetic_v<V>, int> = 0>
_ALWAYS_INLINE_ constexpr explicit operator V() const { return static_cast<V>(value); }
};
// Implicitly zero-constructible as a trivially-constructible type.
static_assert(is_zero_constructible_v<BitField<Error>>);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COMMAND_QUEUE_MT_H
#define COMMAND_QUEUE_MT_H
#pragma once
#include "core/object/worker_thread_pool.h"
#include "core/os/condition_variable.h"
@ -114,7 +113,7 @@ class CommandQueueMT {
uint32_t sync_awaiters = 0;
WorkerThreadPool::TaskID pump_task_id = WorkerThreadPool::INVALID_TASK_ID;
uint64_t flush_read_ptr = 0;
std::atomic<bool> pending;
std::atomic<bool> pending{ false };
template <typename T, typename... Args>
_FORCE_INLINE_ void create_command(Args &&...p_args) {
@ -256,5 +255,3 @@ public:
CommandQueueMT();
~CommandQueueMT();
};
#endif // COMMAND_QUEUE_MT_H

View file

@ -28,44 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COWDATA_H
#define COWDATA_H
#pragma once
#include "core/error/error_macros.h"
#include "core/os/memory.h"
#include "core/templates/safe_refcount.h"
#include "core/templates/span.h"
#include <string.h>
#include <initializer_list>
#include <type_traits>
#include <utility>
template <typename T>
class Vector;
class String;
class Char16String;
class CharString;
template <typename T, typename V>
class VMap;
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
// Silence a false positive warning (see GH-52119).
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wplacement-new"
#endif
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wplacement-new") // Silence a false positive warning (see GH-52119).
template <typename T>
class CowData {
template <typename TV>
friend class Vector;
friend class String;
friend class Char16String;
friend class CharString;
template <typename TV, typename VV>
friend class VMap;
public:
typedef int64_t Size;
typedef uint64_t USize;
@ -134,11 +113,11 @@ private:
return (USize *)((uint8_t *)_ptr - DATA_OFFSET + SIZE_OFFSET);
}
_FORCE_INLINE_ USize _get_alloc_size(USize p_elements) const {
_FORCE_INLINE_ static USize _get_alloc_size(USize p_elements) {
return next_po2(p_elements * sizeof(T));
}
_FORCE_INLINE_ bool _get_alloc_size_checked(USize p_elements, USize *out) const {
_FORCE_INLINE_ static bool _get_alloc_size_checked(USize p_elements, USize *out) {
if (unlikely(p_elements == 0)) {
*out = 0;
return true;
@ -249,9 +228,8 @@ public:
return OK;
}
Size find(const T &p_val, Size p_from = 0) const;
Size rfind(const T &p_val, Size p_from = -1) const;
Size count(const T &p_val) const;
_FORCE_INLINE_ operator Span<T>() const { return Span<T>(ptr(), size()); }
_FORCE_INLINE_ Span<T> span() const { return operator Span<T>(); }
_FORCE_INLINE_ CowData() {}
_FORCE_INLINE_ ~CowData() { _unref(); }
@ -386,14 +364,7 @@ Error CowData<T>::resize(Size p_size) {
}
// construct the newly created elements
if constexpr (!std::is_trivially_constructible_v<T>) {
for (Size i = *_get_size(); i < p_size; i++) {
memnew_placement(&_ptr[i], T);
}
} else if (p_ensure_zero) {
memset((void *)(_ptr + current_size), 0, (p_size - current_size) * sizeof(T));
}
memnew_arr_placement<p_ensure_zero>(_ptr + current_size, p_size - current_size);
*_get_size() = p_size;
@ -434,54 +405,6 @@ Error CowData<T>::_realloc(Size p_alloc_size) {
return OK;
}
template <typename T>
typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
Size ret = -1;
if (p_from < 0 || size() == 0) {
return ret;
}
for (Size i = p_from; i < size(); i++) {
if (get(i) == p_val) {
ret = i;
break;
}
}
return ret;
}
template <typename T>
typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
const Size s = size();
if (p_from < 0) {
p_from = s + p_from;
}
if (p_from < 0 || p_from >= s) {
p_from = s - 1;
}
for (Size i = p_from; i >= 0; i--) {
if (get(i) == p_val) {
return i;
}
}
return -1;
}
template <typename T>
typename CowData<T>::Size CowData<T>::count(const T &p_val) const {
Size amount = 0;
for (Size i = 0; i < size(); i++) {
if (get(i) == p_val) {
amount++;
}
}
return amount;
}
template <typename T>
void CowData<T>::_ref(const CowData *p_from) {
_ref(*p_from);
@ -517,8 +440,8 @@ CowData<T>::CowData(std::initializer_list<T> p_init) {
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
GODOT_GCC_WARNING_POP
#endif // COWDATA_H
// Zero-constructing CowData initializes _ptr to nullptr (and thus empty).
template <typename T>
struct is_zero_constructible<CowData<T>> : std::true_type {};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef HASH_MAP_H
#define HASH_MAP_H
#pragma once
#include "core/os/memory.h"
#include "core/templates/hashfuncs.h"
@ -671,5 +670,3 @@ public:
}
}
};
#endif // HASH_MAP_H

View file

@ -28,14 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef HASH_SET_H
#define HASH_SET_H
#pragma once
#include "core/math/math_funcs.h"
#include "core/os/memory.h"
#include "core/templates/hash_map.h"
#include "core/templates/hashfuncs.h"
#include "core/templates/paged_allocator.h"
/**
* Implementation of Set using a bidi indexed hash map.
@ -479,5 +475,3 @@ public:
}
}
};
#endif // HASH_SET_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef HASHFUNCS_H
#define HASHFUNCS_H
#pragma once
#include "core/math/aabb.h"
#include "core/math/basis.h"
@ -56,6 +55,10 @@
#include "core/templates/rid.h"
#include "core/typedefs.h"
#ifdef _MSC_VER
#include <intrin.h> // Needed for `__umulh` below.
#endif
/**
* Hashing functions
*/
@ -146,7 +149,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_float(float p_in, uint32_t p_see
if (p_in == 0.0f) {
u.f = 0.0;
} else if (Math::is_nan(p_in)) {
u.f = NAN;
u.f = Math::NaN;
} else {
u.f = p_in;
}
@ -169,7 +172,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_double(double p_in, uint32_t p_s
if (p_in == 0.0f) {
u.d = 0.0;
} else if (Math::is_nan(p_in)) {
u.d = NAN;
u.d = Math::NaN;
} else {
u.d = p_in;
}
@ -257,7 +260,7 @@ static _FORCE_INLINE_ uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev
if (p_in == 0.0f) {
u.d = 0.0;
} else if (Math::is_nan(p_in)) {
u.d = NAN;
u.d = Math::NaN;
} else {
u.d = p_in;
}
@ -286,7 +289,7 @@ static _FORCE_INLINE_ uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_pr
if (p_in == 0.0f) {
u.d = 0.0;
} else if (Math::is_nan(p_in)) {
u.d = NAN;
u.d = Math::NaN;
} else {
u.d = p_in;
}
@ -426,116 +429,98 @@ struct HashMapComparatorDefault {
template <>
struct HashMapComparatorDefault<float> {
static bool compare(const float &p_lhs, const float &p_rhs) {
return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs));
return Math::is_same(p_lhs, p_rhs);
}
};
template <>
struct HashMapComparatorDefault<double> {
static bool compare(const double &p_lhs, const double &p_rhs) {
return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs));
return Math::is_same(p_lhs, p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Color> {
static bool compare(const Color &p_lhs, const Color &p_rhs) {
return ((p_lhs.r == p_rhs.r) || (Math::is_nan(p_lhs.r) && Math::is_nan(p_rhs.r))) && ((p_lhs.g == p_rhs.g) || (Math::is_nan(p_lhs.g) && Math::is_nan(p_rhs.g))) && ((p_lhs.b == p_rhs.b) || (Math::is_nan(p_lhs.b) && Math::is_nan(p_rhs.b))) && ((p_lhs.a == p_rhs.a) || (Math::is_nan(p_lhs.a) && Math::is_nan(p_rhs.a)));
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Vector2> {
static bool compare(const Vector2 &p_lhs, const Vector2 &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y)));
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Vector3> {
static bool compare(const Vector3 &p_lhs, const Vector3 &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))) && ((p_lhs.z == p_rhs.z) || (Math::is_nan(p_lhs.z) && Math::is_nan(p_rhs.z)));
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Vector4> {
static bool compare(const Vector4 &p_lhs, const Vector4 &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))) && ((p_lhs.z == p_rhs.z) || (Math::is_nan(p_lhs.z) && Math::is_nan(p_rhs.z))) && ((p_lhs.w == p_rhs.w) || (Math::is_nan(p_lhs.w) && Math::is_nan(p_rhs.w)));
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Rect2> {
static bool compare(const Rect2 &p_lhs, const Rect2 &p_rhs) {
return HashMapComparatorDefault<Vector2>().compare(p_lhs.position, p_rhs.position) && HashMapComparatorDefault<Vector2>().compare(p_lhs.size, p_rhs.size);
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<AABB> {
static bool compare(const AABB &p_lhs, const AABB &p_rhs) {
return HashMapComparatorDefault<Vector3>().compare(p_lhs.position, p_rhs.position) && HashMapComparatorDefault<Vector3>().compare(p_lhs.size, p_rhs.size);
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Plane> {
static bool compare(const Plane &p_lhs, const Plane &p_rhs) {
return HashMapComparatorDefault<Vector3>().compare(p_lhs.normal, p_rhs.normal) && ((p_lhs.d == p_rhs.d) || (Math::is_nan(p_lhs.d) && Math::is_nan(p_rhs.d)));
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Transform2D> {
static bool compare(const Transform2D &p_lhs, const Transform2D &p_rhs) {
for (int i = 0; i < 3; ++i) {
if (!HashMapComparatorDefault<Vector2>().compare(p_lhs.columns[i], p_rhs.columns[i])) {
return false;
}
}
return true;
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Basis> {
static bool compare(const Basis &p_lhs, const Basis &p_rhs) {
for (int i = 0; i < 3; ++i) {
if (!HashMapComparatorDefault<Vector3>().compare(p_lhs.rows[i], p_rhs.rows[i])) {
return false;
}
}
return true;
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Transform3D> {
static bool compare(const Transform3D &p_lhs, const Transform3D &p_rhs) {
return HashMapComparatorDefault<Basis>().compare(p_lhs.basis, p_rhs.basis) && HashMapComparatorDefault<Vector3>().compare(p_lhs.origin, p_rhs.origin);
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Projection> {
static bool compare(const Projection &p_lhs, const Projection &p_rhs) {
for (int i = 0; i < 4; ++i) {
if (!HashMapComparatorDefault<Vector4>().compare(p_lhs.columns[i], p_rhs.columns[i])) {
return false;
}
}
return true;
return p_lhs.is_same(p_rhs);
}
};
template <>
struct HashMapComparatorDefault<Quaternion> {
static bool compare(const Quaternion &p_lhs, const Quaternion &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))) && ((p_lhs.z == p_rhs.z) || (Math::is_nan(p_lhs.z) && Math::is_nan(p_rhs.z))) && ((p_lhs.w == p_rhs.w) || (Math::is_nan(p_lhs.w) && Math::is_nan(p_rhs.w)));
return p_lhs.is_same(p_rhs);
}
};
@ -634,5 +619,3 @@ static _FORCE_INLINE_ uint32_t fastmod(const uint32_t n, const uint64_t c, const
#endif // __SIZEOF_INT128__
#endif // _MSC_VER
}
#endif // HASHFUNCS_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIST_H
#define LIST_H
#pragma once
#include "core/error/error_macros.h"
#include "core/os/memory.h"
@ -829,5 +828,3 @@ void List<T, A>::Element::transfer_to_back(List<T, A> *p_dst_list) {
data = p_dst_list->_data;
p_dst_list->_data->size_cache++;
}
#endif // LIST_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LOCAL_VECTOR_H
#define LOCAL_VECTOR_H
#pragma once
#include "core/error/error_macros.h"
#include "core/os/memory.h"
@ -49,13 +48,12 @@ private:
T *data = nullptr;
public:
T *ptr() {
return data;
}
_FORCE_INLINE_ T *ptr() { return data; }
_FORCE_INLINE_ const T *ptr() const { return data; }
_FORCE_INLINE_ U size() const { return count; }
const T *ptr() const {
return data;
}
_FORCE_INLINE_ Span<T> span() const { return Span(data, count); }
_FORCE_INLINE_ operator Span<T>() const { return span(); }
// Must take a copy instead of a reference (see GH-31736).
_FORCE_INLINE_ void push_back(T p_elem) {
@ -66,7 +64,7 @@ public:
}
if constexpr (!std::is_trivially_constructible_v<T> && !force_trivial) {
memnew_placement(&data[count++], T(p_elem));
memnew_placement(&data[count++], T(std::move(p_elem)));
} else {
data[count++] = std::move(p_elem);
}
@ -105,6 +103,15 @@ public:
return false;
}
bool erase_unordered(const T &p_val) {
int64_t idx = find(p_val);
if (idx >= 0) {
remove_at_unordered(idx);
return true;
}
return false;
}
U erase_multiple_unordered(const T &p_val) {
U from = 0;
U occurrences = 0;
@ -147,7 +154,6 @@ public:
}
}
_FORCE_INLINE_ U size() const { return count; }
void resize(U p_size) {
if (p_size < count) {
if constexpr (!std::is_trivially_destructible_v<T> && !force_trivial) {
@ -163,9 +169,7 @@ public:
CRASH_COND_MSG(!data, "Out of memory");
}
if constexpr (!std::is_trivially_constructible_v<T> && !force_trivial) {
for (U i = count; i < p_size; i++) {
memnew_placement(&data[i], T);
}
memnew_arr_placement(data + count, p_size - count);
}
count = p_size;
}
@ -256,13 +260,14 @@ public:
}
}
int64_t find(const T &p_val, U p_from = 0) const {
for (U i = p_from; i < count; i++) {
if (data[i] == p_val) {
return int64_t(i);
}
int64_t find(const T &p_val, int64_t p_from = 0) const {
if (p_from < 0) {
p_from = size() + p_from;
}
return -1;
if (p_from < 0 || p_from >= size()) {
return -1;
}
return span().find(p_val, p_from);
}
bool has(const T &p_val) const {
@ -281,7 +286,7 @@ public:
}
void sort() {
sort_custom<_DefaultComparator<T>>();
sort_custom<Comparator<T>>();
}
void ordered_insert(T p_val) {
@ -386,4 +391,6 @@ public:
template <typename T, typename U = uint32_t, bool force_trivial = false>
using TightLocalVector = LocalVector<T, U, force_trivial, true>;
#endif // LOCAL_VECTOR_H
// Zero-constructing LocalVector initializes count, capacity and data to 0 and thus empty.
template <typename T, typename U, bool force_trivial, bool tight>
struct is_zero_constructible<LocalVector<T, U, force_trivial, tight>> : std::true_type {};

View file

@ -28,25 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LRU_H
#define LRU_H
#pragma once
#include "core/math/math_funcs.h"
#include "hash_map.h"
#include "list.h"
#if defined(__GNUC__) && !defined(__clang__)
#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Waddress\"");
#define ADDRESS_DIAGNOSTIC_POP \
_Pragma("GCC diagnostic pop");
#else
#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE
#define ADDRESS_DIAGNOSTIC_POP
#endif
template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>, void (*BeforeEvict)(TKey &, TData &) = nullptr>
class LRUCache {
public:
@ -74,11 +60,11 @@ public:
Element n = _list.push_front(Pair(p_key, p_value));
if (e) {
ADDRESS_DIAGNOSTIC_WARNING_DISABLE;
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) {
BeforeEvict((*e)->get().key, (*e)->get().data);
}
ADDRESS_DIAGNOSTIC_POP;
GODOT_GCC_WARNING_POP
_list.erase(*e);
_map.erase(p_key);
}
@ -86,11 +72,11 @@ public:
while (_map.size() > capacity) {
Element d = _list.back();
ADDRESS_DIAGNOSTIC_WARNING_DISABLE
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) {
BeforeEvict(d->get().key, d->get().data);
}
ADDRESS_DIAGNOSTIC_POP
GODOT_GCC_WARNING_POP
_map.erase(d->get().key);
_list.pop_back();
}
@ -143,11 +129,11 @@ public:
capacity = p_capacity;
while (_map.size() > capacity) {
Element d = _list.back();
ADDRESS_DIAGNOSTIC_WARNING_DISABLE;
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) {
BeforeEvict(d->get().key, d->get().data);
}
ADDRESS_DIAGNOSTIC_POP;
GODOT_GCC_WARNING_POP
_map.erase(d->get().key);
_list.pop_back();
}
@ -162,8 +148,3 @@ public:
capacity = p_capacity;
}
};
#undef ADDRESS_DIAGNOSTIC_WARNING_DISABLE
#undef ADDRESS_DIAGNOSTIC_POP
#endif // LRU_H

View file

@ -28,10 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef OA_HASH_MAP_H
#define OA_HASH_MAP_H
#pragma once
#include "core/math/math_funcs.h"
#include "core/os/memory.h"
#include "core/templates/hashfuncs.h"
#include "core/templates/pair.h"
@ -405,5 +403,3 @@ public:
Memory::free_static(hashes);
}
};
#endif // OA_HASH_MAP_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PAGED_ALLOCATOR_H
#define PAGED_ALLOCATOR_H
#pragma once
#include "core/core_globals.h"
#include "core/os/memory.h"
@ -38,7 +37,7 @@
#include "core/typedefs.h"
#include <type_traits>
#include <typeinfo>
#include <typeinfo> // IWYU pragma: keep // Used in macro.
template <typename T, bool thread_safe = false, uint32_t DEFAULT_PAGE_SIZE = 4096>
class PagedAllocator {
@ -177,5 +176,3 @@ public:
}
}
};
#endif // PAGED_ALLOCATOR_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PAGED_ARRAY_H
#define PAGED_ARRAY_H
#pragma once
#include "core/os/memory.h"
#include "core/os/spin_lock.h"
@ -372,5 +371,3 @@ public:
reset();
}
};
#endif // PAGED_ARRAY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PAIR_H
#define PAIR_H
#pragma once
#include "core/templates/hashfuncs.h"
#include "core/typedefs.h"
@ -78,6 +77,10 @@ struct PairHash {
}
};
// Pair is zero-constructible if and only if both constrained types are zero-constructible.
template <typename F, typename S>
struct is_zero_constructible<Pair<F, S>> : std::conjunction<is_zero_constructible<F>, is_zero_constructible<S>> {};
template <typename K, typename V>
struct KeyValue {
const K key;
@ -111,4 +114,6 @@ struct KeyValueSort {
}
};
#endif // PAIR_H
// KeyValue is zero-constructible if and only if both constrained types are zero-constructible.
template <typename K, typename V>
struct is_zero_constructible<KeyValue<K, V>> : std::conjunction<is_zero_constructible<K>, is_zero_constructible<V>> {};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PASS_FUNC_H
#define PASS_FUNC_H
#pragma once
#define PASS0R(m_r, m_name) \
m_r m_name() { \
@ -160,5 +159,3 @@
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { \
PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \
}
#endif // PASS_FUNC_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef POOLED_LIST_H
#define POOLED_LIST_H
#pragma once
// Simple template to provide a pool with O(1) allocate and free.
// The freelist could alternatively be a linked list placed within the unused elements
@ -207,5 +206,3 @@ private:
LocalVector<U, U> _active_map;
LocalVector<U, U> _active_list;
};
#endif // POOLED_LIST_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RB_MAP_H
#define RB_MAP_H
#pragma once
#include "core/error/error_macros.h"
#include "core/os/memory.h"
@ -777,5 +776,3 @@ public:
clear();
}
};
#endif // RB_MAP_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RB_SET_H
#define RB_SET_H
#pragma once
#include "core/os/memory.h"
#include "core/typedefs.h"
@ -715,5 +714,3 @@ public:
clear();
}
};
#endif // RB_SET_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RID_H
#define RID_H
#pragma once
#include "core/typedefs.h"
@ -73,4 +72,5 @@ public:
_ALWAYS_INLINE_ RID() {}
};
#endif // RID_H
template <>
struct is_zero_constructible<RID> : std::true_type {};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RID_OWNER_H
#define RID_OWNER_H
#pragma once
#include "core/os/memory.h"
#include "core/os/mutex.h"
@ -39,7 +38,7 @@
#include "core/templates/safe_refcount.h"
#include <stdio.h>
#include <typeinfo>
#include <typeinfo> // IWYU pragma: keep // Used in macro.
#ifdef SANITIZERS_ENABLED
#ifdef __has_feature
@ -576,5 +575,3 @@ public:
RID_Owner(uint32_t p_target_chunk_byte_size = 65536, uint32_t p_maximum_number_of_elements = 262144) :
alloc(p_target_chunk_byte_size, p_maximum_number_of_elements) {}
};
#endif // RID_OWNER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RING_BUFFER_H
#define RING_BUFFER_H
#pragma once
#include "core/templates/vector.h"
@ -216,5 +215,3 @@ public:
}
~RingBuffer() {}
};
#endif // RING_BUFFER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SAFE_LIST_H
#define SAFE_LIST_H
#pragma once
#include "core/os/memory.h"
#include "core/typedefs.h"
@ -37,7 +36,6 @@
#include <atomic>
#include <functional>
#include <initializer_list>
#include <type_traits>
// Design goals for these classes:
// - Accessing this list with an iterator will never result in a use-after free,
@ -244,5 +242,3 @@ public:
#endif
}
};
#endif // SAFE_LIST_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SAFE_REFCOUNT_H
#define SAFE_REFCOUNT_H
#pragma once
#include "core/typedefs.h"
@ -38,7 +37,7 @@
#endif
#include <atomic>
#include <type_traits>
#include <type_traits> // IWYU pragma: keep // Used in macro.
// Design goals for these classes:
// - No automatic conversions or arithmetic operators,
@ -222,5 +221,3 @@ public:
count.set(p_value);
}
};
#endif // SAFE_REFCOUNT_H

View file

@ -28,12 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SEARCH_ARRAY_H
#define SEARCH_ARRAY_H
#pragma once
#include <core/templates/sort_array.h>
#include "core/typedefs.h"
template <typename T, typename Comparator = _DefaultComparator<T>>
template <typename T, typename Comparator = Comparator<T>>
class SearchArray {
public:
Comparator compare;
@ -63,5 +62,3 @@ public:
return lo;
}
};
#endif // SEARCH_ARRAY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SELF_LIST_H
#define SELF_LIST_H
#pragma once
#include "core/error/error_macros.h"
#include "core/typedefs.h"
@ -201,5 +200,3 @@ public:
}
}
};
#endif // SELF_LIST_H

View file

@ -28,12 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SIMPLE_TYPE_H
#define SIMPLE_TYPE_H
#pragma once
#include <type_traits>
template <typename T>
using GetSimpleTypeT = typename std::remove_cv_t<std::remove_reference_t<T>>;
#endif // SIMPLE_TYPE_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SORT_ARRAY_H
#define SORT_ARRAY_H
#pragma once
#include "core/error/error_macros.h"
#include "core/typedefs.h"
@ -40,18 +39,13 @@
break; \
}
template <typename T>
struct _DefaultComparator {
_FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); }
};
#ifdef DEBUG_ENABLED
#define SORT_ARRAY_VALIDATE_ENABLED true
#else
#define SORT_ARRAY_VALIDATE_ENABLED false
#endif
template <typename T, typename Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
template <typename T, typename Comparator = Comparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
class SortArray {
enum {
INTROSORT_THRESHOLD = 16
@ -316,5 +310,3 @@ public:
introselect(p_first, p_nth, p_last, p_array, bitlog(p_last - p_first) * 2);
}
};
#endif // SORT_ARRAY_H

View file

@ -0,0 +1,124 @@
/**************************************************************************/
/* span.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#pragma once
#include "core/typedefs.h"
// Equivalent of std::span.
// Represents a view into a contiguous memory space.
// DISCLAIMER: This data type does not own the underlying buffer. DO NOT STORE IT.
// Additionally, for the lifetime of the Span, do not resize the buffer, and do not insert or remove elements from it.
// Failure to respect this may lead to crashes or undefined behavior.
template <typename T>
class Span {
const T *_ptr = nullptr;
uint64_t _len = 0;
public:
static constexpr bool is_string = std::disjunction_v<
std::is_same<T, char>,
std::is_same<T, char16_t>,
std::is_same<T, char32_t>,
std::is_same<T, wchar_t>>;
_FORCE_INLINE_ constexpr Span() = default;
_FORCE_INLINE_ constexpr Span(const T *p_ptr, uint64_t p_len) :
_ptr(p_ptr), _len(p_len) {}
// Allows creating Span directly from C arrays and string literals.
template <size_t N>
_FORCE_INLINE_ constexpr Span(const T (&p_array)[N]) :
_ptr(p_array), _len(N) {
if constexpr (is_string) {
// Cut off the \0 terminator implicitly added to string literals.
if (N > 0 && p_array[N - 1] == '\0') {
_len--;
}
}
}
_FORCE_INLINE_ constexpr uint64_t size() const { return _len; }
_FORCE_INLINE_ constexpr bool is_empty() const { return _len == 0; }
_FORCE_INLINE_ constexpr const T *ptr() const { return _ptr; }
// NOTE: Span subscripts sanity check the bounds to avoid undefined behavior.
// This is slower than direct buffer access and can prevent autovectorization.
// If the bounds are known, use ptr() subscript instead.
_FORCE_INLINE_ constexpr const T &operator[](uint64_t p_idx) const {
CRASH_COND(p_idx >= _len);
return _ptr[p_idx];
}
_FORCE_INLINE_ constexpr const T *begin() const { return _ptr; }
_FORCE_INLINE_ constexpr const T *end() const { return _ptr + _len; }
// Algorithms.
constexpr int64_t find(const T &p_val, uint64_t p_from = 0) const;
constexpr int64_t rfind(const T &p_val, uint64_t p_from) const;
_FORCE_INLINE_ constexpr int64_t rfind(const T &p_val) const { return rfind(p_val, size() - 1); }
constexpr uint64_t count(const T &p_val) const;
};
template <typename T>
constexpr int64_t Span<T>::find(const T &p_val, uint64_t p_from) const {
for (uint64_t i = p_from; i < size(); i++) {
if (ptr()[i] == p_val) {
return i;
}
}
return -1;
}
template <typename T>
constexpr int64_t Span<T>::rfind(const T &p_val, uint64_t p_from) const {
for (int64_t i = p_from; i >= 0; i--) {
if (ptr()[i] == p_val) {
return i;
}
}
return -1;
}
template <typename T>
constexpr uint64_t Span<T>::count(const T &p_val) const {
uint64_t amount = 0;
for (uint64_t i = 0; i < size(); i++) {
if (ptr()[i] == p_val) {
amount++;
}
}
return amount;
}
// Zero-constructing Span initializes _ptr and _len to 0 (and thus empty).
template <typename T>
struct is_zero_constructible<Span<T>> : std::true_type {};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef TUPLE_H
#define TUPLE_H
#pragma once
// Simple recursive Tuple type that has no runtime overhead.
//
@ -86,6 +85,10 @@ struct Tuple<T, Rest...> : Tuple<Rest...> {
value(std::forward<F>(f)) {}
};
// Tuple is zero-constructible if and only if all constrained types are zero-constructible.
template <typename... Types>
struct is_zero_constructible<Tuple<Types...>> : std::conjunction<is_zero_constructible<Types>...> {};
template <size_t I, typename Tuple>
struct TupleGet;
@ -117,5 +120,3 @@ template <size_t I, typename... Types>
_FORCE_INLINE_ const auto &tuple_get(const Tuple<Types...> &t) {
return TupleGet<I, Tuple<Types...>>::tuple_get(t);
}
#endif // TUPLE_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VECTOR_H
#define VECTOR_H
#pragma once
/**
* @class Vector
@ -40,14 +39,14 @@
*/
#include "core/error/error_macros.h"
#include "core/os/memory.h"
#include "core/templates/cowdata.h"
#include "core/templates/search_array.h"
#include "core/templates/sort_array.h"
#include <climits>
#include <initializer_list>
#include <utility>
template <typename T>
class Vector;
template <typename T>
class VectorWriteProxy {
@ -90,21 +89,41 @@ public:
_FORCE_INLINE_ T *ptrw() { return _cowdata.ptrw(); }
_FORCE_INLINE_ const T *ptr() const { return _cowdata.ptr(); }
_FORCE_INLINE_ Size size() const { return _cowdata.size(); }
_FORCE_INLINE_ operator Span<T>() const { return _cowdata.span(); }
_FORCE_INLINE_ Span<T> span() const { return _cowdata.span(); }
_FORCE_INLINE_ void clear() { resize(0); }
_FORCE_INLINE_ bool is_empty() const { return _cowdata.is_empty(); }
_FORCE_INLINE_ T get(Size p_index) { return _cowdata.get(p_index); }
_FORCE_INLINE_ const T &get(Size p_index) const { return _cowdata.get(p_index); }
_FORCE_INLINE_ void set(Size p_index, const T &p_elem) { _cowdata.set(p_index, p_elem); }
_FORCE_INLINE_ Size size() const { return _cowdata.size(); }
Error resize(Size p_size) { return _cowdata.resize(p_size); }
Error resize_zeroed(Size p_size) { return _cowdata.template resize<true>(p_size); }
_FORCE_INLINE_ const T &operator[](Size p_index) const { return _cowdata.get(p_index); }
// Must take a copy instead of a reference (see GH-31736).
Error insert(Size p_pos, T p_val) { return _cowdata.insert(p_pos, p_val); }
Size find(const T &p_val, Size p_from = 0) const { return _cowdata.find(p_val, p_from); }
Size rfind(const T &p_val, Size p_from = -1) const { return _cowdata.rfind(p_val, p_from); }
Size count(const T &p_val) const { return _cowdata.count(p_val); }
Size find(const T &p_val, Size p_from = 0) const {
if (p_from < 0) {
p_from = size() + p_from;
}
if (p_from < 0 || p_from >= size()) {
return -1;
}
return span().find(p_val, p_from);
}
Size rfind(const T &p_val, Size p_from = -1) const {
if (p_from < 0) {
p_from = size() + p_from;
}
if (p_from < 0 || p_from >= size()) {
return -1;
}
return span().rfind(p_val, p_from);
}
Size count(const T &p_val) const { return span().count(p_val); }
// Must take a copy instead of a reference (see GH-31736).
void append_array(Vector<T> p_other);
@ -112,7 +131,7 @@ public:
_FORCE_INLINE_ bool has(const T &p_val) const { return find(p_val) != -1; }
void sort() {
sort_custom<_DefaultComparator<T>>();
sort_custom<Comparator<T>>();
}
template <typename Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, typename... Args>
@ -128,7 +147,7 @@ public:
}
Size bsearch(const T &p_value, bool p_before) {
return bsearch_custom<_DefaultComparator<T>>(p_value, p_before);
return bsearch_custom<Comparator<T>>(p_value, p_before);
}
template <typename Comparator, typename Value, typename... Args>
@ -151,7 +170,7 @@ public:
insert(i, p_val);
}
void operator=(const Vector &p_from) { _cowdata._ref(p_from._cowdata); }
void operator=(const Vector &p_from) { _cowdata = p_from._cowdata; }
void operator=(Vector &&p_from) { _cowdata = std::move(p_from._cowdata); }
Vector<uint8_t> to_byte_array() const {
@ -288,9 +307,8 @@ public:
_FORCE_INLINE_ Vector() {}
_FORCE_INLINE_ Vector(std::initializer_list<T> p_init) :
_cowdata(p_init) {}
_FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); }
_FORCE_INLINE_ Vector(Vector &&p_from) :
_cowdata(std::move(p_from._cowdata)) {}
_FORCE_INLINE_ Vector(const Vector &p_from) = default;
_FORCE_INLINE_ Vector(Vector &&p_from) = default;
_FORCE_INLINE_ ~Vector() {}
};
@ -333,4 +351,6 @@ void Vector<T>::fill(T p_elem) {
}
}
#endif // VECTOR_H
// Zero-constructing Vector initializes CowData.ptr() to nullptr and thus empty.
template <typename T>
struct is_zero_constructible<Vector<T>> : std::true_type {};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VMAP_H
#define VMAP_H
#pragma once
#include "core/templates/cowdata.h"
#include "core/typedefs.h"
@ -196,11 +195,7 @@ public:
_FORCE_INLINE_ VMap() {}
_FORCE_INLINE_ VMap(std::initializer_list<T> p_init) :
_cowdata(p_init) {}
_FORCE_INLINE_ VMap(const VMap &p_from) { _cowdata._ref(p_from._cowdata); }
_FORCE_INLINE_ VMap(const VMap &p_from) = default;
inline void operator=(const VMap &p_from) {
_cowdata._ref(p_from._cowdata);
}
void operator=(const VMap &p_from) { _cowdata = p_from._cowdata; }
};
#endif // VMAP_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VSET_H
#define VSET_H
#pragma once
#include "core/templates/vector.h"
#include "core/typedefs.h"
@ -142,5 +141,3 @@ public:
_FORCE_INLINE_ VSet(std::initializer_list<T> p_init) :
_data(p_init) {}
};
#endif // VSET_H