1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

AK: Add a CommonType<Ts...> type trait

Also adds a simple-ish test for CommonType.
This commit is contained in:
Ali Mohammad Pur 2021-07-22 19:01:05 +04:30 committed by Andreas Kling
parent ccd19d464e
commit 6c9ef20010
2 changed files with 45 additions and 3 deletions

View file

@ -246,3 +246,23 @@ TEST_CASE(IsDestructible)
EXPECT_TRAIT_FALSE(IsDestructible, C);
EXPECT_TRAIT_FALSE(IsTriviallyDestructible, C);
}
TEST_CASE(CommonType)
{
using TCommon0 = CommonType<int, float, char>;
EXPECT_VARIADIC_TRAIT_TRUE(IsSame, TCommon0, float);
using TCommon1 = CommonType<int, int, int, char>;
EXPECT_VARIADIC_TRAIT_TRUE(IsSame, TCommon1, int);
struct Foo {
};
using TCommon2 = CommonType<Foo, Foo, Foo>;
EXPECT_VARIADIC_TRAIT_TRUE(IsSame, TCommon2, Foo);
struct Bar {
operator Foo();
};
using TCommon3 = CommonType<Bar, Foo, Bar>;
EXPECT_VARIADIC_TRAIT_TRUE(IsSame, TCommon3, Foo);
}