mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
This commit is contained in:
parent
d8d16dea95
commit
a6e4482080
41 changed files with 650 additions and 662 deletions
|
@ -46,14 +46,14 @@ TEST_CASE(TestIndexSequence)
|
|||
{
|
||||
constexpr auto integer_seq1 = IntegerSequence<int, 0, 1, 2, 3, 4> {};
|
||||
constexpr auto integer_seq2 = MakeIntegerSequence<int, 5> {};
|
||||
static_assert(IsSame<decltype(integer_seq1), decltype(integer_seq2)>::value, "");
|
||||
static_assert(IsSame<decltype(integer_seq1), decltype(integer_seq2)>, "");
|
||||
|
||||
static_assert(integer_seq1.size() == 5, "");
|
||||
static_assert(integer_seq2.size() == 5, "");
|
||||
|
||||
constexpr auto index_seq1 = IndexSequence<0, 1, 2> {};
|
||||
constexpr auto index_seq2 = MakeIndexSequence<3> {};
|
||||
static_assert(IsSame<decltype(index_seq1), decltype(index_seq2)>::value, "");
|
||||
static_assert(IsSame<decltype(index_seq1), decltype(index_seq2)>, "");
|
||||
|
||||
verify_sequence(MakeIndexSequence<10> {}, std::initializer_list<unsigned> { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U });
|
||||
verify_sequence(MakeIntegerSequence<long, 16> {}, std::initializer_list<long> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
|
||||
|
@ -62,9 +62,9 @@ TEST_CASE(TestIndexSequence)
|
|||
TEST_CASE(TypeList)
|
||||
{
|
||||
using MyTypes = TypeList<int, bool, char>;
|
||||
static_assert(IsSame<MyTypes::Type<0>, int>::value, "");
|
||||
static_assert(IsSame<MyTypes::Type<1>, bool>::value, "");
|
||||
static_assert(IsSame<MyTypes::Type<2>, char>::value, "");
|
||||
static_assert(IsSame<MyTypes::Type<0>, int>, "");
|
||||
static_assert(IsSame<MyTypes::Type<1>, bool>, "");
|
||||
static_assert(IsSame<MyTypes::Type<2>, char>, "");
|
||||
}
|
||||
|
||||
TEST_MAIN(IndexSequence);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue