From 703c57a119d5ae48eb0d463b0f6d3f607931b300 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 11 Jan 2021 17:59:02 -0500 Subject: common/parent_of_member: Replace TYPED_STORAGE define with template alias Provides the same construct, but makes it obey namespacing. --- src/common/parent_of_member.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/common/parent_of_member.h') 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 -struct TypedStorage { +struct TypedStorageImpl { std::aligned_storage_t storage_; }; +} // namespace detail -#define TYPED_STORAGE(...) TypedStorage<__VA_ARGS__, sizeof(__VA_ARGS__), alignof(__VA_ARGS__)> +template +using TypedStorage = detail::TypedStorageImpl; template -static constexpr T* GetPointer(TYPED_STORAGE(T) & ts) { +static constexpr T* GetPointer(TypedStorage& ts) { return static_cast(static_cast(std::addressof(ts.storage_))); } template -static constexpr const T* GetPointer(const TYPED_STORAGE(T) & ts) { +static constexpr const T* GetPointer(const TypedStorage& ts) { return static_cast(static_cast(std::addressof(ts.storage_))); } @@ -72,7 +74,7 @@ struct OffsetOfCalculator { union Union { char c{}; UnionHolder first_union; - TYPED_STORAGE(ParentType) parent; + TypedStorage parent; constexpr Union() : c() {} }; -- cgit v1.2.3