fix(templates): fix FSingleton not working correctly with EBO on MSVC
make CAnyCustomStorage satisfy the concept of FSingleton
This commit is contained in:
parent
a4ac19673f
commit
6a70d4273e
@ -15,29 +15,32 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
|
|
||||||
// TAny's CustomStorage concept, see FAnyDefaultStorage
|
// TAny's CustomStorage concept, see FAnyDefaultStorage
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept CAnyCustomStorage =
|
concept CAnyCustomStorage = CDefaultConstructible<T>
|
||||||
CSameAs<decltype(T::InlineSize), const size_t> &&
|
&& !CCopyConstructible<T> && !CMoveConstructible<T>
|
||||||
CSameAs<decltype(T::InlineAlignment), const size_t> &&
|
&& !CCopyAssignable<T> && !CMoveAssignable<T>
|
||||||
requires(const T& A)
|
&& CDestructible<T>
|
||||||
|
&& CSameAs<decltype(T::InlineSize), const size_t>
|
||||||
|
&& CSameAs<decltype(T::InlineAlignment), const size_t>
|
||||||
|
&& requires(const T& A)
|
||||||
{
|
{
|
||||||
{ A.InlineAllocation() } -> CSameAs<const void*>;
|
{ A.InlineAllocation() } -> CSameAs<const void*>;
|
||||||
{ A.HeapAllocation() } -> CSameAs<void*>;
|
{ A.HeapAllocation() } -> CSameAs<void*>;
|
||||||
{ A.TypeInfo() } -> CSameAs<uintptr>;
|
{ A.TypeInfo() } -> CSameAs<uintptr>;
|
||||||
} &&
|
}
|
||||||
requires(T& A)
|
&& requires(T& A)
|
||||||
{
|
{
|
||||||
{ A.InlineAllocation() } -> CSameAs<void*>;
|
{ A.InlineAllocation() } -> CSameAs<void*>;
|
||||||
{ A.HeapAllocation() } -> CSameAs<void*&>;
|
{ A.HeapAllocation() } -> CSameAs<void*&>;
|
||||||
{ A.TypeInfo() } -> CSameAs<uintptr&>;
|
{ A.TypeInfo() } -> CSameAs<uintptr&>;
|
||||||
} &&
|
}
|
||||||
requires(T& A, const T& B, T&& C)
|
&& requires(T& A, const T& B, T&& C)
|
||||||
{
|
{
|
||||||
A.CopyCustom(B);
|
A.CopyCustom(B);
|
||||||
A.MoveCustom(MoveTemp(C));
|
A.MoveCustom(MoveTemp(C));
|
||||||
};
|
};
|
||||||
|
|
||||||
// TAny's default storage structure
|
// TAny's default storage structure
|
||||||
struct alignas(16) FAnyDefaultStorage
|
struct alignas(16) FAnyDefaultStorage : FSingleton
|
||||||
{
|
{
|
||||||
// The built-in copy/move operators are disabled and CopyCustom/MoveCustom is used instead of them
|
// The built-in copy/move operators are disabled and CopyCustom/MoveCustom is used instead of them
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ NAMESPACE_PRIVATE_END
|
|||||||
template <typename T, bool bIsRef = false> requires (CTriviallyCopyable<T>
|
template <typename T, bool bIsRef = false> requires (CTriviallyCopyable<T>
|
||||||
&& CCopyConstructible<T> && CMoveConstructible<T>
|
&& CCopyConstructible<T> && CMoveConstructible<T>
|
||||||
&& CCopyAssignable<T> && CMoveAssignable<T>)
|
&& CCopyAssignable<T> && CMoveAssignable<T>)
|
||||||
struct TAtomic : public FSingleton
|
struct TAtomic : FSingleton
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ using TAtomicRef = TAtomic<T, true>;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
TAtomic(T) -> TAtomic<T>;
|
TAtomic(T) -> TAtomic<T>;
|
||||||
|
|
||||||
struct FAtomicFlag : public FSingleton
|
struct FAtomicFlag : FSingleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename CallableType>
|
template <typename CallableType>
|
||||||
struct alignas(16) FFunctionStorage
|
struct alignas(16) FFunctionStorage : FSingleton
|
||||||
{
|
{
|
||||||
//~ Begin CAnyCustomStorage Interface
|
//~ Begin CAnyCustomStorage Interface
|
||||||
inline static constexpr size_t InlineSize = 64 - sizeof(uintptr) - sizeof(CallableType);
|
inline static constexpr size_t InlineSize = 64 - sizeof(uintptr) - sizeof(CallableType);
|
||||||
|
@ -20,7 +20,15 @@ struct FNonmovable
|
|||||||
FNonmovable& operator=(FNonmovable&&) = delete;
|
FNonmovable& operator=(FNonmovable&&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FSingleton : public FNoncopyable, public FNonmovable { };
|
// Multiple inheritance is no longer used here, as that would break the EBO in MSVC
|
||||||
|
struct FSingleton // : FNoncopyable, FNonmovable
|
||||||
|
{
|
||||||
|
FSingleton() = default;
|
||||||
|
FSingleton(const FSingleton&) = delete;
|
||||||
|
FSingleton(FSingleton&&) = delete;
|
||||||
|
FSingleton& operator=(const FSingleton&) = delete;
|
||||||
|
FSingleton& operator=(FSingleton&&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
NAMESPACE_MODULE_END(Utility)
|
NAMESPACE_MODULE_END(Utility)
|
||||||
NAMESPACE_MODULE_END(Redcraft)
|
NAMESPACE_MODULE_END(Redcraft)
|
||||||
|
Loading…
Reference in New Issue
Block a user