1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

AK/Variant: Deduplicate the contained types

This allows the construction of `Variant<int, int, int>`.
While this might not seem useful, it is very useful for making variants
that contain a series of member function pointers, which I plan to use
in LibGL for glGenLists() and co.
This commit is contained in:
Ali Mohammad Pur 2021-05-09 08:22:43 +04:30 committed by Linus Groh
parent 3038b6b7dc
commit 4fdbac236d
2 changed files with 66 additions and 3 deletions

View file

@ -110,3 +110,10 @@ TEST_CASE(moved_from_state)
auto same_contents = __builtin_memcmp(&bunch_of_values, &optionally_a_bunch_of_values.get<Vector<i32>>(), sizeof(bunch_of_values)) == 0;
EXPECT(same_contents);
}
TEST_CASE(duplicated_types)
{
Variant<int, int, int, int> its_just_an_int { 42 };
EXPECT(its_just_an_int.has<int>());
EXPECT_EQ(its_just_an_int.get<int>(), 42);
}