diff options
author | rtk0c <[email protected]> | 2022-06-28 12:17:48 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-28 12:17:48 -0700 |
commit | 6839736b8283a59eb743e1f6058c7d266a3e7f36 (patch) | |
tree | c9fafde01740753a93c3bf3830faa790b88b001c /source/10-common | |
parent | 8a244363c9171946aa6e4552ce0dcfc8edf761cb (diff) |
Changeset: 78 Replace "class" keyword in templates with "typename"
Diffstat (limited to 'source/10-common')
-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 |
12 files changed, 29 insertions, 29 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 |