summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/templates
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-03-10 16:02:43 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-03-10 16:02:43 -0500
commit87f5fb06912d19b3ff3ba80b747fcea3023a1ed5 (patch)
treec081d3e0b7703194c8162125ee7b138bb2c557d3 /include/godot_cpp/templates
parentcc1217a43cab5ff8377c2f5e53301fda67def95e (diff)
downloadredot-cpp-87f5fb06912d19b3ff3ba80b747fcea3023a1ed5.tar.gz
Enforce template syntax `typename` over `class`
Diffstat (limited to 'include/godot_cpp/templates')
-rw-r--r--include/godot_cpp/templates/cowdata.hpp32
-rw-r--r--include/godot_cpp/templates/hash_map.hpp10
-rw-r--r--include/godot_cpp/templates/hash_set.hpp6
-rw-r--r--include/godot_cpp/templates/hashfuncs.hpp10
-rw-r--r--include/godot_cpp/templates/list.hpp10
-rw-r--r--include/godot_cpp/templates/local_vector.hpp6
-rw-r--r--include/godot_cpp/templates/pair.hpp16
-rw-r--r--include/godot_cpp/templates/rb_map.hpp2
-rw-r--r--include/godot_cpp/templates/rb_set.hpp2
-rw-r--r--include/godot_cpp/templates/rid_owner.hpp6
-rw-r--r--include/godot_cpp/templates/safe_refcount.hpp4
-rw-r--r--include/godot_cpp/templates/search_array.hpp2
-rw-r--r--include/godot_cpp/templates/self_list.hpp2
-rw-r--r--include/godot_cpp/templates/sort_array.hpp4
-rw-r--r--include/godot_cpp/templates/thread_work_pool.hpp6
-rw-r--r--include/godot_cpp/templates/vector.hpp16
-rw-r--r--include/godot_cpp/templates/vmap.hpp2
-rw-r--r--include/godot_cpp/templates/vset.hpp2
18 files changed, 69 insertions, 69 deletions
diff --git a/include/godot_cpp/templates/cowdata.hpp b/include/godot_cpp/templates/cowdata.hpp
index f2959d1..dcb74ec 100644
--- a/include/godot_cpp/templates/cowdata.hpp
+++ b/include/godot_cpp/templates/cowdata.hpp
@@ -43,13 +43,13 @@
namespace godot {
-template <class T>
+template <typename T>
class Vector;
-template <class T, class V>
+template <typename T, typename V>
class VMap;
-template <class T>
+template <typename T>
class CharStringT;
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
@@ -60,15 +60,15 @@ static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
#pragma GCC diagnostic ignored "-Wplacement-new"
#endif
-template <class T>
+template <typename T>
class CowData {
- template <class TV>
+ template <typename TV>
friend class Vector;
- template <class TV, class VV>
+ template <typename TV, typename VV>
friend class VMap;
- template <class TS>
+ template <typename TS>
friend class CharStringT;
public:
@@ -248,7 +248,7 @@ public:
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
};
-template <class T>
+template <typename T>
void CowData<T>::_unref(void *p_data) {
if (!p_data) {
return;
@@ -275,7 +275,7 @@ void CowData<T>::_unref(void *p_data) {
Memory::free_static(((uint8_t *)p_data) - DATA_OFFSET, false);
}
-template <class T>
+template <typename T>
typename CowData<T>::USize CowData<T>::_copy_on_write() {
if (!_ptr) {
return 0;
@@ -315,7 +315,7 @@ typename CowData<T>::USize CowData<T>::_copy_on_write() {
return rc;
}
-template <class T>
+template <typename T>
template <bool p_ensure_zero>
Error CowData<T>::resize(Size p_size) {
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
@@ -407,7 +407,7 @@ Error CowData<T>::resize(Size p_size) {
return OK;
}
-template <class T>
+template <typename T>
typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
Size ret = -1;
@@ -425,7 +425,7 @@ typename CowData<T>::Size CowData<T>::find(const T &p_val, Size p_from) const {
return ret;
}
-template <class T>
+template <typename T>
typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
const Size s = size();
@@ -444,7 +444,7 @@ typename CowData<T>::Size CowData<T>::rfind(const T &p_val, Size p_from) const {
return -1;
}
-template <class T>
+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++) {
@@ -455,12 +455,12 @@ typename CowData<T>::Size CowData<T>::count(const T &p_val) const {
return amount;
}
-template <class T>
+template <typename T>
void CowData<T>::_ref(const CowData *p_from) {
_ref(*p_from);
}
-template <class T>
+template <typename T>
void CowData<T>::_ref(const CowData &p_from) {
if (_ptr == p_from._ptr) {
return; // self assign, do nothing.
@@ -478,7 +478,7 @@ void CowData<T>::_ref(const CowData &p_from) {
}
}
-template <class T>
+template <typename T>
CowData<T>::~CowData() {
_unref(_ptr);
}
diff --git a/include/godot_cpp/templates/hash_map.hpp b/include/godot_cpp/templates/hash_map.hpp
index 77c7b7a..59cd8e0 100644
--- a/include/godot_cpp/templates/hash_map.hpp
+++ b/include/godot_cpp/templates/hash_map.hpp
@@ -52,7 +52,7 @@ namespace godot {
* The assignment operator copy the pairs from one map to the other.
*/
-template <class TKey, class TValue>
+template <typename TKey, typename TValue>
struct HashMapElement {
HashMapElement *next = nullptr;
HashMapElement *prev = nullptr;
@@ -62,10 +62,10 @@ struct HashMapElement {
data(p_key, p_value) {}
};
-template <class TKey, class TValue,
- class Hasher = HashMapHasherDefault,
- class Comparator = HashMapComparatorDefault<TKey>,
- class Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
+template <typename TKey, typename TValue,
+ typename Hasher = HashMapHasherDefault,
+ typename Comparator = HashMapComparatorDefault<TKey>,
+ typename Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
class HashMap {
public:
const uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
diff --git a/include/godot_cpp/templates/hash_set.hpp b/include/godot_cpp/templates/hash_set.hpp
index 884ae4d..1845a1b 100644
--- a/include/godot_cpp/templates/hash_set.hpp
+++ b/include/godot_cpp/templates/hash_set.hpp
@@ -48,9 +48,9 @@ namespace godot {
*
*/
-template <class TKey,
- class Hasher = HashMapHasherDefault,
- class Comparator = HashMapComparatorDefault<TKey>>
+template <typename TKey,
+ typename Hasher = HashMapHasherDefault,
+ typename Comparator = HashMapComparatorDefault<TKey>>
class HashSet {
public:
static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
diff --git a/include/godot_cpp/templates/hashfuncs.hpp b/include/godot_cpp/templates/hashfuncs.hpp
index d6f3400..40b10a9 100644
--- a/include/godot_cpp/templates/hashfuncs.hpp
+++ b/include/godot_cpp/templates/hashfuncs.hpp
@@ -253,7 +253,7 @@ static _FORCE_INLINE_ uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev
return ((p_prev << 5) + p_prev) + hash_one_uint64(u.i);
}
-template <class T>
+template <typename T>
static _FORCE_INLINE_ uint32_t hash_make_uint32_t(T p_in) {
union {
T t;
@@ -286,7 +286,7 @@ static _FORCE_INLINE_ uint64_t hash_djb2_one_64(uint64_t p_in, uint64_t p_prev =
return ((p_prev << 5) + p_prev) ^ p_in;
}
-template <class T>
+template <typename T>
static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) {
union {
T t;
@@ -298,15 +298,15 @@ static _FORCE_INLINE_ uint64_t hash_make_uint64_t(T p_in) {
return _u._u64;
}
-template <class T>
+template <typename T>
class Ref;
struct HashMapHasherDefault {
// Generic hash function for any type.
- template <class T>
+ template <typename T>
static _FORCE_INLINE_ uint32_t hash(const T *p_pointer) { return hash_one_uint64((uint64_t)p_pointer); }
- template <class T>
+ template <typename T>
static _FORCE_INLINE_ uint32_t hash(const Ref<T> &p_ref) { return hash_one_uint64((uint64_t)p_ref.operator->()); }
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
diff --git a/include/godot_cpp/templates/list.hpp b/include/godot_cpp/templates/list.hpp
index 2c8a7c8..376e3ea 100644
--- a/include/godot_cpp/templates/list.hpp
+++ b/include/godot_cpp/templates/list.hpp
@@ -45,7 +45,7 @@
namespace godot {
-template <class T, class A = DefaultAllocator>
+template <typename T, typename A = DefaultAllocator>
class List {
struct _Data;
@@ -410,7 +410,7 @@ public:
/**
* find an element in the list,
*/
- template <class T_v>
+ template <typename T_v>
Element *find(const T_v &p_val) {
Element *it = front();
while (it) {
@@ -646,7 +646,7 @@ public:
sort_custom<Comparator<T>>();
}
- template <class C>
+ template <typename C>
void sort_custom_inplace() {
if (size() < 2) {
return;
@@ -693,7 +693,7 @@ public:
_data->last = to;
}
- template <class C>
+ template <typename C>
struct AuxiliaryComparator {
C compare;
_FORCE_INLINE_ bool operator()(const Element *a, const Element *b) const {
@@ -701,7 +701,7 @@ public:
}
};
- template <class C>
+ template <typename C>
void sort_custom() {
// this version uses auxiliary memory for speed.
// if you don't want to use auxiliary memory, use the in_place version
diff --git a/include/godot_cpp/templates/local_vector.hpp b/include/godot_cpp/templates/local_vector.hpp
index 8ce4e65..5dad32e 100644
--- a/include/godot_cpp/templates/local_vector.hpp
+++ b/include/godot_cpp/templates/local_vector.hpp
@@ -43,7 +43,7 @@ namespace godot {
// If tight, it grows strictly as much as needed.
// Otherwise, it grows exponentially (the default and what you want in most cases).
-template <class T, class U = uint32_t, bool force_trivial = false, bool tight = false>
+template <typename T, typename U = uint32_t, bool force_trivial = false, bool tight = false>
class LocalVector {
private:
U count = 0;
@@ -257,7 +257,7 @@ public:
return -1;
}
- template <class C>
+ template <typename C>
void sort_custom() {
U len = count;
if (len == 0) {
@@ -331,7 +331,7 @@ public:
}
};
-template <class T, class U = uint32_t, bool force_trivial = false>
+template <typename T, typename U = uint32_t, bool force_trivial = false>
using TightLocalVector = LocalVector<T, U, force_trivial, true>;
} // namespace godot
diff --git a/include/godot_cpp/templates/pair.hpp b/include/godot_cpp/templates/pair.hpp
index ed35302..f875413 100644
--- a/include/godot_cpp/templates/pair.hpp
+++ b/include/godot_cpp/templates/pair.hpp
@@ -33,7 +33,7 @@
namespace godot {
-template <class F, class S>
+template <typename F, typename S>
struct Pair {
F first;
S second;
@@ -49,17 +49,17 @@ struct Pair {
}
};
-template <class F, class S>
+template <typename F, typename S>
bool operator==(const Pair<F, S> &pair, const Pair<F, S> &other) {
return (pair.first == other.first) && (pair.second == other.second);
}
-template <class F, class S>
+template <typename F, typename S>
bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) {
return (pair.first != other.first) || (pair.second != other.second);
}
-template <class F, class S>
+template <typename F, typename S>
struct PairSort {
bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const {
if (A.first != B.first) {
@@ -69,7 +69,7 @@ struct PairSort {
}
};
-template <class K, class V>
+template <typename K, typename V>
struct KeyValue {
const K key;
V value;
@@ -85,17 +85,17 @@ struct KeyValue {
}
};
-template <class K, class V>
+template <typename K, typename V>
bool operator==(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
return (pair.key == other.key) && (pair.value == other.value);
}
-template <class K, class V>
+template <typename K, typename V>
bool operator!=(const KeyValue<K, V> &pair, const KeyValue<K, V> &other) {
return (pair.key != other.key) || (pair.value != other.value);
}
-template <class K, class V>
+template <typename K, typename V>
struct KeyValueSort {
bool operator()(const KeyValue<K, V> &A, const KeyValue<K, V> &B) const {
return A.key < B.key;
diff --git a/include/godot_cpp/templates/rb_map.hpp b/include/godot_cpp/templates/rb_map.hpp
index cce1e91..6ab71fd 100644
--- a/include/godot_cpp/templates/rb_map.hpp
+++ b/include/godot_cpp/templates/rb_map.hpp
@@ -40,7 +40,7 @@ namespace godot {
// based on the very nice implementation of rb-trees by:
// https://web.archive.org/web/20120507164830/https://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
-template <class K, class V, class C = Comparator<K>, class A = DefaultAllocator>
+template <typename K, typename V, typename C = Comparator<K>, typename A = DefaultAllocator>
class RBMap {
enum Color {
RED,
diff --git a/include/godot_cpp/templates/rb_set.hpp b/include/godot_cpp/templates/rb_set.hpp
index c803f81..69aa8d7 100644
--- a/include/godot_cpp/templates/rb_set.hpp
+++ b/include/godot_cpp/templates/rb_set.hpp
@@ -38,7 +38,7 @@
namespace godot {
-template <class T, class C = Comparator<T>, class A = DefaultAllocator>
+template <typename T, typename C = Comparator<T>, typename A = DefaultAllocator>
class RBSet {
enum Color {
RED,
diff --git a/include/godot_cpp/templates/rid_owner.hpp b/include/godot_cpp/templates/rid_owner.hpp
index 005fc87..1dd4a39 100644
--- a/include/godot_cpp/templates/rid_owner.hpp
+++ b/include/godot_cpp/templates/rid_owner.hpp
@@ -42,7 +42,7 @@
namespace godot {
-template <class T, bool THREAD_SAFE = false>
+template <typename T, bool THREAD_SAFE = false>
class RID_Alloc {
T **chunks = nullptr;
uint32_t **free_list_chunks = nullptr;
@@ -347,7 +347,7 @@ public:
}
};
-template <class T, bool THREAD_SAFE = false>
+template <typename T, bool THREAD_SAFE = false>
class RID_PtrOwner {
RID_Alloc<T *, THREAD_SAFE> alloc;
@@ -406,7 +406,7 @@ public:
alloc(p_target_chunk_byte_size) {}
};
-template <class T, bool THREAD_SAFE = false>
+template <typename T, bool THREAD_SAFE = false>
class RID_Owner {
RID_Alloc<T, THREAD_SAFE> alloc;
diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp
index 519bbf7..12e6840 100644
--- a/include/godot_cpp/templates/safe_refcount.hpp
+++ b/include/godot_cpp/templates/safe_refcount.hpp
@@ -57,7 +57,7 @@ namespace godot {
static_assert(sizeof(SafeFlag) == sizeof(bool)); \
static_assert(alignof(SafeFlag) == alignof(bool));
-template <class T>
+template <typename T>
class SafeNumeric {
std::atomic<T> value;
@@ -195,7 +195,7 @@ public:
#else
-template <class T>
+template <typename T>
class SafeNumeric {
protected:
T value;
diff --git a/include/godot_cpp/templates/search_array.hpp b/include/godot_cpp/templates/search_array.hpp
index ce2713b..11a9db5 100644
--- a/include/godot_cpp/templates/search_array.hpp
+++ b/include/godot_cpp/templates/search_array.hpp
@@ -35,7 +35,7 @@
namespace godot {
-template <class T, class Comparator = _DefaultComparator<T>>
+template <typename T, typename Comparator = _DefaultComparator<T>>
class SearchArray {
public:
Comparator compare;
diff --git a/include/godot_cpp/templates/self_list.hpp b/include/godot_cpp/templates/self_list.hpp
index 3bb13a3..f7a65f6 100644
--- a/include/godot_cpp/templates/self_list.hpp
+++ b/include/godot_cpp/templates/self_list.hpp
@@ -36,7 +36,7 @@
namespace godot {
-template <class T>
+template <typename T>
class SelfList {
public:
class List {
diff --git a/include/godot_cpp/templates/sort_array.hpp b/include/godot_cpp/templates/sort_array.hpp
index 5dda578..7ce5c78 100644
--- a/include/godot_cpp/templates/sort_array.hpp
+++ b/include/godot_cpp/templates/sort_array.hpp
@@ -41,7 +41,7 @@ namespace godot {
break; \
}
-template <class T>
+template <typename T>
struct _DefaultComparator {
_FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); }
};
@@ -52,7 +52,7 @@ struct _DefaultComparator {
#define SORT_ARRAY_VALIDATE_ENABLED false
#endif
-template <class T, class Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
+template <typename T, typename Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
class SortArray {
enum {
INTROSORT_THRESHOLD = 16
diff --git a/include/godot_cpp/templates/thread_work_pool.hpp b/include/godot_cpp/templates/thread_work_pool.hpp
index a3efd42..cb20c6e 100644
--- a/include/godot_cpp/templates/thread_work_pool.hpp
+++ b/include/godot_cpp/templates/thread_work_pool.hpp
@@ -52,7 +52,7 @@ class ThreadWorkPool {
virtual ~BaseWork() = default;
};
- template <class C, class M, class U>
+ template <typename C, typename M, typename U>
struct Work : public BaseWork {
C *instance;
M method;
@@ -94,7 +94,7 @@ class ThreadWorkPool {
}
public:
- template <class C, class M, class U>
+ template <typename C, typename M, typename U>
void begin_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
ERR_FAIL_NULL(threads); // Never initialized.
ERR_FAIL_COND(current_work != nullptr);
@@ -145,7 +145,7 @@ public:
current_work = nullptr;
}
- template <class C, class M, class U>
+ template <typename C, typename M, typename U>
void do_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
switch (p_elements) {
case 0:
diff --git a/include/godot_cpp/templates/vector.hpp b/include/godot_cpp/templates/vector.hpp
index 05b7184..aaa84f3 100644
--- a/include/godot_cpp/templates/vector.hpp
+++ b/include/godot_cpp/templates/vector.hpp
@@ -47,7 +47,7 @@
namespace godot {
-template <class T>
+template <typename T>
class VectorWriteProxy {
public:
_FORCE_INLINE_ T &operator[](typename CowData<T>::Size p_index) {
@@ -57,7 +57,7 @@ public:
}
};
-template <class T>
+template <typename T>
class Vector {
friend class VectorWriteProxy<T>;
@@ -110,7 +110,7 @@ public:
sort_custom<_DefaultComparator<T>>();
}
- template <class Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, class... Args>
+ template <typename Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, typename... Args>
void sort_custom(Args &&...args) {
Size len = _cowdata.size();
if (len == 0) {
@@ -126,7 +126,7 @@ public:
return bsearch_custom<_DefaultComparator<T>>(p_value, p_before);
}
- template <class Comparator, class Value, class... Args>
+ template <typename Comparator, typename Value, typename... Args>
Size bsearch_custom(const Value &p_value, bool p_before, Args &&...args) {
SearchArray<T, Comparator> search{ args... };
return search.bisect(ptrw(), size(), p_value, p_before);
@@ -293,7 +293,7 @@ public:
_FORCE_INLINE_ ~Vector() {}
};
-template <class T>
+template <typename T>
void Vector<T>::reverse() {
for (Size i = 0; i < size() / 2; i++) {
T *p = ptrw();
@@ -301,7 +301,7 @@ void Vector<T>::reverse() {
}
}
-template <class T>
+template <typename T>
void Vector<T>::append_array(Vector<T> p_other) {
const Size ds = p_other.size();
if (ds == 0) {
@@ -314,7 +314,7 @@ void Vector<T>::append_array(Vector<T> p_other) {
}
}
-template <class T>
+template <typename T>
bool Vector<T>::push_back(T p_elem) {
Error err = resize(size() + 1);
ERR_FAIL_COND_V(err, true);
@@ -323,7 +323,7 @@ bool Vector<T>::push_back(T p_elem) {
return false;
}
-template <class T>
+template <typename T>
void Vector<T>::fill(T p_elem) {
T *p = ptrw();
for (Size i = 0; i < size(); i++) {
diff --git a/include/godot_cpp/templates/vmap.hpp b/include/godot_cpp/templates/vmap.hpp
index 881ac25..926ccd3 100644
--- a/include/godot_cpp/templates/vmap.hpp
+++ b/include/godot_cpp/templates/vmap.hpp
@@ -35,7 +35,7 @@
namespace godot {
-template <class T, class V>
+template <typename T, typename V>
class VMap {
public:
struct Pair {
diff --git a/include/godot_cpp/templates/vset.hpp b/include/godot_cpp/templates/vset.hpp
index 29f0cef..ce21ba8 100644
--- a/include/godot_cpp/templates/vset.hpp
+++ b/include/godot_cpp/templates/vset.hpp
@@ -35,7 +35,7 @@
namespace godot {
-template <class T>
+template <typename T>
class VSet {
Vector<T> _data;