From 6839736b8283a59eb743e1f6058c7d266a3e7f36 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Tue, 28 Jun 2022 12:17:48 -0700 Subject: Changeset: 78 Replace "class" keyword in templates with "typename" --- source/10-common/Enum.hpp | 4 ++-- source/10-common/PodVector.hpp | 2 +- source/10-common/RTTI.hpp | 10 +++++----- source/10-common/RapidJsonHelper.hpp | 4 ++-- source/10-common/RcPtr.hpp | 6 +++--- source/10-common/Rect.hpp | 4 ++-- source/10-common/ScopeGuard.hpp | 4 ++-- source/10-common/SmallVector.cpp | 6 +++--- source/10-common/SmallVector.hpp | 10 +++++----- source/10-common/Type2ObjectMap.hpp | 2 +- source/10-common/Utils.hpp | 2 +- source/10-common/YCombinator.hpp | 4 ++-- source/30-game/CommonVertexIndex.cpp | 14 +++++++------- source/30-game/EditorUtils.hpp | 2 +- source/30-game/Material.cpp | 2 +- source/30-game/World.cpp | 2 +- 16 files changed, 39 insertions(+), 39 deletions(-) (limited to 'source') 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 #include -template +template class EnumFlags { public: using Enum = TEnum; @@ -103,7 +103,7 @@ public: }; // Helper class for enumerating enum elements for ImGui::Begin/EndCombo -template +template 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 #include -template +template 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 -template +template bool is_a(TBase* t) { assert(t != nullptr); return T::IsInstance(t); } -template +template bool is_a_nullable(TBase* t) { if (t) { return is_a(t); @@ -17,7 +17,7 @@ bool is_a_nullable(TBase* t) { } } -template +template T* dyn_cast(TBase* t) { assert(t != nullptr); if (T::IsInstance(t)) { @@ -27,7 +27,7 @@ T* dyn_cast(TBase* t) { } } -template +template 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 +template T* dyn_cast_nullable(TBase* t) { if (!t) return nullptr; return dyn_cast(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 StringRef(std::string_view str) { str.size()); } -template +template 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 +template 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 > +template > class RcPtr : TDeleter { private: static_assert(std::is_base_of_v); @@ -78,7 +78,7 @@ public: return *this; } - template + template requires std::is_base_of_v operator RcPtr() const { return RcPtr(mPtr); @@ -96,7 +96,7 @@ public: return mPtr == ptr; } - template + template bool operator==(const RcPtr& 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 +template class Rect { public: using ScalarType = T; @@ -152,7 +152,7 @@ public: return *this; } - template + template Rect Cast() const { return { static_cast(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 -template +template class ScopeGuard { private: TCleanupFunc mFunc; @@ -49,7 +49,7 @@ public: } }; -template +template 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 +template static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { constexpr size_t MaxSize = std::numeric_limits::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 +template void* SmallVectorBase::mallocForGrow(size_t MinSize, size_t TSize, size_t& NewCapacity) { NewCapacity = getNewCapacity(MinSize, TSize, this->capacity()); return malloc(NewCapacity * TSize); } // Note: Moving this function into the header may cause performance regression. -template +template void SmallVectorBase::grow_pod(void* FirstEl, size_t MinSize, size_t TSize) { size_t NewCapacity = getNewCapacity(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, where a /// 32 bit size would limit the vector to ~4GB. SmallVectors are used for /// buffering bitcode output - which can exceed 4GB. -template +template class SmallVectorBase { protected: void* BeginX; @@ -97,12 +97,12 @@ protected: } }; -template +template using SmallVectorSizeType = typename std::conditional= 8, uint64_t, uint32_t>::type; /// Figure out the offset of the first element. -template +template struct SmallVectorAlignmentAndSize { alignas(SmallVectorBase>) char Base[sizeof( SmallVectorBase>)]; @@ -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 + template 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 + template 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 + template TValue* Find() { return const_cast(const_cast(this)->Find()); } 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 +template void HashCombine(std::size_t& seed, const T& v) { seed ^= std::hash{}(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 +template struct YCombinator { // NOTE: implicit constructor allows initializing this Func func; - template + template decltype(auto) operator()(Ts&&... args) const { // NOTE: static_cast(args)... is equivalent to std::forward(args)... // written this way so that we don't have to include , 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 +template 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 +template 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 +template static void AssignPositions(TVertex vertices[4], const Rect& rect) { // Top left vertices[0].x = rect.x0(); @@ -40,7 +40,7 @@ static void AssignPositions(TVertex vertices[4], const Rect& rect) { vertices[3].y = rect.y1(); } -template +template 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 +template 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 +template 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 +template 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 +template 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 +template TUniform& ObtainUniform(Shader* shader, const char* name, std::vector& 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 namespace ProjectBrussel_UNITY_ID { -template +template void CallGameObjectRecursive(GameObject* start, TFunction&& func) { PodVector stack; stack.push_back(start); -- cgit v1.2.3-70-g09d2