diff options
-rw-r--r-- | source/10-common/Enum.hpp | 4 | ||||
-rw-r--r-- | source/10-common/PodVector.hpp | 2 | ||||
-rw-r--r-- | source/10-common/RTTI.hpp | 10 | ||||
-rw-r--r-- | source/10-common/RapidJsonHelper.hpp | 4 | ||||
-rw-r--r-- | source/10-common/RcPtr.hpp | 6 | ||||
-rw-r--r-- | source/10-common/Rect.hpp | 4 | ||||
-rw-r--r-- | source/10-common/ScopeGuard.hpp | 4 | ||||
-rw-r--r-- | source/10-common/SmallVector.cpp | 6 | ||||
-rw-r--r-- | source/10-common/SmallVector.hpp | 10 | ||||
-rw-r--r-- | source/10-common/Type2ObjectMap.hpp | 2 | ||||
-rw-r--r-- | source/10-common/Utils.hpp | 2 | ||||
-rw-r--r-- | source/10-common/YCombinator.hpp | 4 | ||||
-rw-r--r-- | source/30-game/CommonVertexIndex.cpp | 14 | ||||
-rw-r--r-- | source/30-game/EditorUtils.hpp | 2 | ||||
-rw-r--r-- | source/30-game/Material.cpp | 2 | ||||
-rw-r--r-- | source/30-game/World.cpp | 2 |
16 files changed, 39 insertions, 39 deletions
diff --git a/source/10-common/Enum.hpp b/source/10-common/Enum.hpp index 5d75955..7afbe8e 100644 --- a/source/10-common/Enum.hpp +++ b/source/10-common/Enum.hpp @@ -3,7 +3,7 @@ #include <initializer_list> #include <type_traits> -template <class TEnum> +template <typename TEnum> class EnumFlags { public: using Enum = TEnum; @@ -103,7 +103,7 @@ public: }; // Helper class for enumerating enum elements for ImGui::Begin/EndCombo -template <class TEnum> +template <typename TEnum> struct EnumElement { const char* name; TEnum value; diff --git a/source/10-common/PodVector.hpp b/source/10-common/PodVector.hpp index 74e99d6..bd92e7d 100644 --- a/source/10-common/PodVector.hpp +++ b/source/10-common/PodVector.hpp @@ -8,7 +8,7 @@ #include <cstring> #include <span> -template <class T> +template <typename T> class PodVector { public: using value_type = T; diff --git a/source/10-common/RTTI.hpp b/source/10-common/RTTI.hpp index bc0d289..bd9475b 100644 --- a/source/10-common/RTTI.hpp +++ b/source/10-common/RTTI.hpp @@ -2,13 +2,13 @@ #include <cassert> -template <class T, class TBase> +template <typename T, typename TBase> bool is_a(TBase* t) { assert(t != nullptr); return T::IsInstance(t); } -template <class T, class TBase> +template <typename T, typename TBase> bool is_a_nullable(TBase* t) { if (t) { return is_a<T, TBase>(t); @@ -17,7 +17,7 @@ bool is_a_nullable(TBase* t) { } } -template <class T, class TBase> +template <typename T, typename TBase> T* dyn_cast(TBase* t) { assert(t != nullptr); if (T::IsInstance(t)) { @@ -27,7 +27,7 @@ T* dyn_cast(TBase* t) { } } -template <class T, class TBase> +template <typename T, typename TBase> const T* dyn_cast(const TBase* t) { assert(t != nullptr); if (T::IsInstance(t)) { @@ -37,7 +37,7 @@ const T* dyn_cast(const TBase* t) { } } -template <class T, class TBase> +template <typename T, typename TBase> T* dyn_cast_nullable(TBase* t) { if (!t) return nullptr; return dyn_cast<T, TBase>(t); diff --git a/source/10-common/RapidJsonHelper.hpp b/source/10-common/RapidJsonHelper.hpp index 75cd93a..008c6bb 100644 --- a/source/10-common/RapidJsonHelper.hpp +++ b/source/10-common/RapidJsonHelper.hpp @@ -75,7 +75,7 @@ inline GenericStringRef<char> StringRef(std::string_view str) { str.size()); } -template <class TIter, class TSentienl> +template <typename TIter, typename TSentienl> rapidjson::Value WriteVectorPrimitives(rapidjson::Document& root, TIter begin, TSentienl end) { using TElement = typename TIter::value_type; @@ -92,7 +92,7 @@ rapidjson::Value WriteVectorPrimitives(rapidjson::Document& root, TIter begin, T return list; } -template <class TContainer> +template <typename TContainer> bool ReadVectorPrimitives(const rapidjson::Value& value, TContainer& list) { using TElement = typename TContainer::value_type; diff --git a/source/10-common/RcPtr.hpp b/source/10-common/RcPtr.hpp index 130b2b2..e3e420e 100644 --- a/source/10-common/RcPtr.hpp +++ b/source/10-common/RcPtr.hpp @@ -15,7 +15,7 @@ public: uint32_t weakCount = 0; // TODO implement }; -template <class T, class TDeleter = DefaultDeleter<T>> +template <typename T, typename TDeleter = DefaultDeleter<T>> class RcPtr : TDeleter { private: static_assert(std::is_base_of_v<RefCounted, T>); @@ -78,7 +78,7 @@ public: return *this; } - template <class TBase> + template <typename TBase> requires std::is_base_of_v<TBase, T> operator RcPtr<TBase>() const { return RcPtr<TBase>(mPtr); @@ -96,7 +96,7 @@ public: return mPtr == ptr; } - template <class TThat> + template <typename TThat> bool operator==(const RcPtr<TThat>& ptr) const { return mPtr == ptr.Get(); } diff --git a/source/10-common/Rect.hpp b/source/10-common/Rect.hpp index 89d9b01..86a1268 100644 --- a/source/10-common/Rect.hpp +++ b/source/10-common/Rect.hpp @@ -4,7 +4,7 @@ /// Rect is a rectangle representation based on a point and a dimensions, in television coordinate space /// (x increases from left to right, y increases from top to bottom). -template <class T> +template <typename T> class Rect { public: using ScalarType = T; @@ -152,7 +152,7 @@ public: return *this; } - template <class TTarget> + template <typename TTarget> Rect<TTarget> Cast() const { return { static_cast<TTarget>(x), diff --git a/source/10-common/ScopeGuard.hpp b/source/10-common/ScopeGuard.hpp index 28f3385..4e1a348 100644 --- a/source/10-common/ScopeGuard.hpp +++ b/source/10-common/ScopeGuard.hpp @@ -4,7 +4,7 @@ #include <utility> -template <class TCleanupFunc> +template <typename TCleanupFunc> class ScopeGuard { private: TCleanupFunc mFunc; @@ -49,7 +49,7 @@ public: } }; -template <class T> +template <typename T> auto GuardDeletion(T* ptr) { return ScopeGuard([ptr]() { delete ptr; diff --git a/source/10-common/SmallVector.cpp b/source/10-common/SmallVector.cpp index c38e8a7..65953f0 100644 --- a/source/10-common/SmallVector.cpp +++ b/source/10-common/SmallVector.cpp @@ -79,7 +79,7 @@ static void report_at_maximum_capacity(size_t MaxSize) { } // Note: Moving this function into the header may cause performance regression. -template <class Size_T> +template <typename Size_T> static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { constexpr size_t MaxSize = std::numeric_limits<Size_T>::max(); @@ -102,14 +102,14 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { } // Note: Moving this function into the header may cause performance regression. -template <class Size_T> +template <typename Size_T> void* SmallVectorBase<Size_T>::mallocForGrow(size_t MinSize, size_t TSize, size_t& NewCapacity) { NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity()); return malloc(NewCapacity * TSize); } // Note: Moving this function into the header may cause performance regression. -template <class Size_T> +template <typename Size_T> void SmallVectorBase<Size_T>::grow_pod(void* FirstEl, size_t MinSize, size_t TSize) { size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity()); void* NewElts; diff --git a/source/10-common/SmallVector.hpp b/source/10-common/SmallVector.hpp index e33a25d..3fc7519 100644 --- a/source/10-common/SmallVector.hpp +++ b/source/10-common/SmallVector.hpp @@ -55,7 +55,7 @@ class iterator_range; /// Using 64 bit size is desirable for cases like SmallVector<char>, where a /// 32 bit size would limit the vector to ~4GB. SmallVectors are used for /// buffering bitcode output - which can exceed 4GB. -template <class Size_T> +template <typename Size_T> class SmallVectorBase { protected: void* BeginX; @@ -97,12 +97,12 @@ protected: } }; -template <class T> +template <typename T> using SmallVectorSizeType = typename std::conditional<sizeof(T) < 4 && sizeof(void*) >= 8, uint64_t, uint32_t>::type; /// Figure out the offset of the first element. -template <class T, typename = void> +template <typename T, typename = void> struct SmallVectorAlignmentAndSize { alignas(SmallVectorBase<SmallVectorSizeType<T>>) char Base[sizeof( SmallVectorBase<SmallVectorSizeType<T>>)]; @@ -222,7 +222,7 @@ protected: /// Reserve enough space to add one element, and return the updated element /// pointer in case it was a reference to the storage. - template <class U> + template <typename U> static const T* reserveForParamAndGetAddressImpl(U* This, const T& Elt, size_t N) { size_t NewSize = This->size() + N; if (LLVM_LIKELY(NewSize <= This->capacity())) @@ -768,7 +768,7 @@ public: } private: - template <class ArgType> + template <typename ArgType> iterator insert_one_impl(iterator I, ArgType&& Elt) { // Callers ensure that ArgType is derived from T. static_assert( diff --git a/source/10-common/Type2ObjectMap.hpp b/source/10-common/Type2ObjectMap.hpp index 24c45f3..0976d2e 100644 --- a/source/10-common/Type2ObjectMap.hpp +++ b/source/10-common/Type2ObjectMap.hpp @@ -27,7 +27,7 @@ public: // TODO } - template <class TType> + template <typename TType> TValue* Find() { return const_cast<TValue*>(const_cast<const Type2ObjectMap*>(this)->Find<TType>()); } diff --git a/source/10-common/Utils.hpp b/source/10-common/Utils.hpp index fdf0f5d..82569d8 100644 --- a/source/10-common/Utils.hpp +++ b/source/10-common/Utils.hpp @@ -43,7 +43,7 @@ bool LineContains(glm::ivec2 p1, glm::ivec2 p2, glm::ivec2 candidate); bool IsColinear(glm::ivec2 p1, glm::ivec2 p2); -template <class T> +template <typename T> void HashCombine(std::size_t& seed, const T& v) { seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } diff --git a/source/10-common/YCombinator.hpp b/source/10-common/YCombinator.hpp index b1d2350..2da06c8 100644 --- a/source/10-common/YCombinator.hpp +++ b/source/10-common/YCombinator.hpp @@ -1,11 +1,11 @@ #pragma once -template <class Func> +template <typename Func> struct YCombinator { // NOTE: implicit constructor allows initializing this Func func; - template <class... Ts> + template <typename... Ts> decltype(auto) operator()(Ts&&... args) const { // NOTE: static_cast<Ts>(args)... is equivalent to std::forward<Ts>(args)... // written this way so that we don't have to include <utility>, as well as reducing template instanciations to help compile time diff --git a/source/30-game/CommonVertexIndex.cpp b/source/30-game/CommonVertexIndex.cpp index 786274e..e9a3ce6 100644 --- a/source/30-game/CommonVertexIndex.cpp +++ b/source/30-game/CommonVertexIndex.cpp @@ -1,6 +1,6 @@ #include "CommonVertexIndex.hpp" -template <class TNumber> +template <typename TNumber> static void AssignIndices(TNumber indices[6], TNumber startIdx) { // Triangle #1 indices[0] = startIdx + 1; // Top right @@ -12,7 +12,7 @@ static void AssignIndices(TNumber indices[6], TNumber startIdx) { indices[5] = startIdx + 2; // Bottom right } -template <class TNumber> +template <typename TNumber> static void AssignIndices(TNumber indices[6], TNumber topLeft, TNumber topRight, TNumber bottomRight, TNumber bottomLeft) { // Triangle #1 indices[0] = topRight; @@ -24,7 +24,7 @@ static void AssignIndices(TNumber indices[6], TNumber topLeft, TNumber topRight, indices[5] = bottomRight; } -template <class TVertex> +template <typename TVertex> static void AssignPositions(TVertex vertices[4], const Rect<float>& rect) { // Top left vertices[0].x = rect.x0(); @@ -40,7 +40,7 @@ static void AssignPositions(TVertex vertices[4], const Rect<float>& rect) { vertices[3].y = rect.y1(); } -template <class TVertex> +template <typename TVertex> static void AssignPositions(TVertex vertices[4], glm::vec2 bl, glm::vec2 tr) { // Top left vertices[0].x = bl.x; @@ -56,7 +56,7 @@ static void AssignPositions(TVertex vertices[4], glm::vec2 bl, glm::vec2 tr) { vertices[3].y = bl.y; } -template <class TVertex> +template <typename TVertex> static void AssignDepths(TVertex vertices[4], float z) { for (int i = 0; i < 4; ++i) { auto& vert = vertices[i]; @@ -64,7 +64,7 @@ static void AssignDepths(TVertex vertices[4], float z) { } } -template <class TVertex> +template <typename TVertex> static void AssignTexCoords(TVertex vertices[4], const Subregion& texcoords) { // Top left vertices[0].u = texcoords.u0; @@ -80,7 +80,7 @@ static void AssignTexCoords(TVertex vertices[4], const Subregion& texcoords) { vertices[3].v = texcoords.v0; } -template <class TVertex> +template <typename TVertex> static void AssignColors(TVertex vertices[4], RgbaColor color) { for (int i = 0; i < 4; ++i) { auto& vert = vertices[i]; diff --git a/source/30-game/EditorUtils.hpp b/source/30-game/EditorUtils.hpp index 9d15f61..96e92d3 100644 --- a/source/30-game/EditorUtils.hpp +++ b/source/30-game/EditorUtils.hpp @@ -65,7 +65,7 @@ float CalcImageWidth(glm::vec2 original, float targetHeight); ImVec2 FitImage(glm::vec2 original); // TODO get kind from T -template <class T> +template <typename T> T* SimpleIresReceptor(T* existing, IEditor& editor, IresObject::Kind kind) { if (existing) { existing->ShowReference(editor); diff --git a/source/30-game/Material.cpp b/source/30-game/Material.cpp index 9b0c42d..4443ae5 100644 --- a/source/30-game/Material.cpp +++ b/source/30-game/Material.cpp @@ -33,7 +33,7 @@ bool TryFindShaderId(Shader* shader, std::string_view name, int& out) { return true; } -template <class TUniform> +template <typename TUniform> TUniform& ObtainUniform(Shader* shader, const char* name, std::vector<TUniform>& uniforms, GLint location) { for (auto& uniform : uniforms) { if (uniform.location == location) { diff --git a/source/30-game/World.cpp b/source/30-game/World.cpp index d4a8344..5d3a8c5 100644 --- a/source/30-game/World.cpp +++ b/source/30-game/World.cpp @@ -6,7 +6,7 @@ #include <glad/glad.h> namespace ProjectBrussel_UNITY_ID { -template <class TFunction> +template <typename TFunction> void CallGameObjectRecursive(GameObject* start, TFunction&& func) { PodVector<GameObject*> stack; stack.push_back(start); |