diff options
author | bunnei <bunneidev@gmail.com> | 2021-01-12 05:47:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-12 05:47:30 +0100 |
commit | 99d2d770624a341c529fc89726951079dd45c651 (patch) | |
tree | 00a028d13aa7cdbe60c9c7145b7fdadb2a8765d2 /src | |
parent | Merge pull request #5266 from bunnei/kernel-synch (diff) | |
parent | common/parent_of_member: Replace TYPED_STORAGE define with template alias (diff) | |
download | yuzu-99d2d770624a341c529fc89726951079dd45c651.tar yuzu-99d2d770624a341c529fc89726951079dd45c651.tar.gz yuzu-99d2d770624a341c529fc89726951079dd45c651.tar.bz2 yuzu-99d2d770624a341c529fc89726951079dd45c651.tar.lz yuzu-99d2d770624a341c529fc89726951079dd45c651.tar.xz yuzu-99d2d770624a341c529fc89726951079dd45c651.tar.zst yuzu-99d2d770624a341c529fc89726951079dd45c651.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/common/intrusive_red_black_tree.h | 4 | ||||
-rw-r--r-- | src/common/parent_of_member.h | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index 929b5497e..fb55de94e 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -533,7 +533,7 @@ private: } private: - static constexpr TYPED_STORAGE(Derived) DerivedStorage = {}; + static constexpr TypedStorage<Derived> DerivedStorage = {}; static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage)); }; @@ -549,7 +549,7 @@ public: using TreeTypeImpl = impl::IntrusiveRedBlackTreeImpl; static constexpr bool IsValid() { - TYPED_STORAGE(Derived) DerivedStorage = {}; + TypedStorage<Derived> DerivedStorage = {}; return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage); } diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h index 1af31ee44..d9a14529d 100644 --- a/src/common/parent_of_member.h +++ b/src/common/parent_of_member.h @@ -10,21 +10,23 @@ #include "common/common_types.h" namespace Common { - +namespace detail { template <typename T, size_t Size, size_t Align> -struct TypedStorage { +struct TypedStorageImpl { std::aligned_storage_t<Size, Align> storage_; }; +} // namespace detail -#define TYPED_STORAGE(...) TypedStorage<__VA_ARGS__, sizeof(__VA_ARGS__), alignof(__VA_ARGS__)> +template <typename T> +using TypedStorage = detail::TypedStorageImpl<T, sizeof(T), alignof(T)>; template <typename T> -static constexpr T* GetPointer(TYPED_STORAGE(T) & ts) { +static constexpr T* GetPointer(TypedStorage<T>& ts) { return static_cast<T*>(static_cast<void*>(std::addressof(ts.storage_))); } template <typename T> -static constexpr const T* GetPointer(const TYPED_STORAGE(T) & ts) { +static constexpr const T* GetPointer(const TypedStorage<T>& ts) { return static_cast<const T*>(static_cast<const void*>(std::addressof(ts.storage_))); } @@ -72,7 +74,7 @@ struct OffsetOfCalculator { union Union { char c{}; UnionHolder first_union; - TYPED_STORAGE(ParentType) parent; + TypedStorage<ParentType> parent; constexpr Union() : c() {} }; |