mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK: Add IsTriviallyRelocatable type trait
This commit is contained in:
committed by
Jelle Raaijmakers
parent
c173a66754
commit
8dd3c20436
Notes:
github-actions[bot]
2026-03-19 13:23:22 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/8dd3c204367 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7784 Reviewed-by: https://github.com/gmta ✅
@@ -551,6 +551,9 @@ inline constexpr bool IsMoveAssignable = IsAssignable<AddLvalueReference<T>, Add
|
||||
template<typename T>
|
||||
inline constexpr bool IsTriviallyMoveAssignable = IsTriviallyAssignable<AddLvalueReference<T>, AddRvalueReference<T>>;
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool IsTriviallyRelocatable = IsTriviallyMoveConstructible<T> && IsTriviallyDestructible<T>;
|
||||
|
||||
template<typename T, template<typename...> typename U>
|
||||
inline constexpr bool IsSpecializationOf = false;
|
||||
|
||||
@@ -716,6 +719,7 @@ using AK::Detail::IsTriviallyCopyConstructible;
|
||||
using AK::Detail::IsTriviallyDestructible;
|
||||
using AK::Detail::IsTriviallyMoveAssignable;
|
||||
using AK::Detail::IsTriviallyMoveConstructible;
|
||||
using AK::Detail::IsTriviallyRelocatable;
|
||||
using AK::Detail::IsUnion;
|
||||
using AK::Detail::IsUnsigned;
|
||||
using AK::Detail::IsVoid;
|
||||
|
||||
@@ -243,6 +243,32 @@ TEST_CASE(IsDestructible)
|
||||
EXPECT_TRAIT_FALSE(IsTriviallyDestructible, C);
|
||||
}
|
||||
|
||||
TEST_CASE(IsTriviallyRelocatable)
|
||||
{
|
||||
EXPECT_TRAIT_TRUE(IsTriviallyRelocatable, int, float, char, Empty);
|
||||
EXPECT_TRAIT_TRUE(IsTriviallyRelocatable, int*, Empty*);
|
||||
|
||||
struct TriviallyRelocatable {
|
||||
};
|
||||
EXPECT_TRAIT_TRUE(IsTriviallyRelocatable, TriviallyRelocatable);
|
||||
|
||||
struct NonTriviallyRelocatable {
|
||||
NonTriviallyRelocatable(NonTriviallyRelocatable&&) { }
|
||||
~NonTriviallyRelocatable() { }
|
||||
};
|
||||
EXPECT_TRAIT_FALSE(IsTriviallyRelocatable, NonTriviallyRelocatable);
|
||||
|
||||
struct NonTrivialMove {
|
||||
NonTrivialMove(NonTrivialMove&&) { }
|
||||
};
|
||||
EXPECT_TRAIT_FALSE(IsTriviallyRelocatable, NonTrivialMove);
|
||||
|
||||
struct NonTrivialDestructor {
|
||||
~NonTrivialDestructor() { }
|
||||
};
|
||||
EXPECT_TRAIT_FALSE(IsTriviallyRelocatable, NonTrivialDestructor);
|
||||
}
|
||||
|
||||
TEST_CASE(CommonType)
|
||||
{
|
||||
using TCommon0 = CommonType<int, float, char>;
|
||||
|
||||
Reference in New Issue
Block a user