diff options
| author | swarmer <[email protected]> | 2026-03-02 20:00:43 +0300 |
|---|---|---|
| committer | swarmer <[email protected]> | 2026-03-02 21:31:50 +0300 |
| commit | 508ecbd2e171ac98da140da5511c87162d18838b (patch) | |
| tree | c788c63f4eb50a3e3d201f8e3b835d5209813e46 /util | |
| parent | 45f56309705ff183646c4ea3ae533648bde55858 (diff) | |
allow NTL::TConcat to concatenate more than two lists
commit_hash:4a7ae26132b5605dfc289d75b3adc330ab842fd3
Diffstat (limited to 'util')
| -rw-r--r-- | util/generic/typelist.h | 7 | ||||
| -rw-r--r-- | util/generic/typelist_ut.cpp | 18 |
2 files changed, 24 insertions, 1 deletions
diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 28c221b01c3..41039aa4c72 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -67,7 +67,7 @@ using TFixedWidthUnsignedInts = TTypeList<ui8, ui16, ui32, ui64>; using TFloats = TTypeList<float, double, long double>; namespace NTL { - template <class T1, class T2> + template <class T1, class T2, class... TL> struct TConcat; template <class... R1, class... R2> @@ -75,6 +75,11 @@ namespace NTL { using type = TTypeList<R1..., R2...>; }; + template <class... R1, class... R2, class... TL> + struct TConcat<TTypeList<R1...>, TTypeList<R2...>, TL...> { + using type = typename TConcat<TTypeList<R1..., R2...>, TL...>::type; + }; + template <class TResult, class T, class... Ts> struct TUniqueImpl; diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp index 3765285488f..683be34dcdc 100644 --- a/util/generic/typelist_ut.cpp +++ b/util/generic/typelist_ut.cpp @@ -19,6 +19,7 @@ class TTypeListTest: public TTestBase { UNIT_TEST(TestSelectBy); UNIT_TEST(TestUnique); UNIT_TEST(TestUniqueTypeList); + UNIT_TEST(TestConcat); UNIT_TEST_SUITE_END(); public: @@ -100,6 +101,23 @@ public: UnitAssertTypesEqual<TUniqueTypeList<TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts>, TTypeList<TSignedInts>>(); UnitAssertTypesEqual<TUniqueTypeList<TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts, TSignedInts>, TUniqueTypeList<TSignedInts, TSignedInts, TSignedInts>>(); } + + void TestConcat() { + using TFirstListType = TTypeList<TA, TB*>; + using TSecondListType = TTypeList<const TC&>; + using TThirdListType = TTypeList<int, double, TA>; + using TListType = NTL::TConcat<TFirstListType, TSecondListType, TThirdListType>::type; + + UNIT_ASSERT(TListType::THave<TA>::value); + UNIT_ASSERT(TListType::THave<TB*>::value); + UNIT_ASSERT(TListType::THave<int>::value); + UNIT_ASSERT(TListType::THave<double>::value); + UNIT_ASSERT(!TListType::THave<std::string>::value); + UNIT_ASSERT(!TListType::THave<TB>::value); + UNIT_ASSERT(TListType::THave<const TC&>::value); + UNIT_ASSERT(!TListType::THave<TC&>::value); + UNIT_ASSERT_VALUES_EQUAL(TListType::Length, TFirstListType::Length + TSecondListType::Length + TThirdListType::Length); + } }; UNIT_TEST_SUITE_REGISTRATION(TTypeListTest); |
