From f8a4d388c5baf838d22c1273250099a01f0f76ea Mon Sep 17 00:00:00 2001 From: sha512sum Date: Wed, 28 Feb 2024 20:23:41 +0000 Subject: [PATCH] Add + operator and Filter to TypeList --- include/utempl/type_list.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/utempl/type_list.hpp b/include/utempl/type_list.hpp index 232ec36..41a9b6d 100644 --- a/include/utempl/type_list.hpp +++ b/include/utempl/type_list.hpp @@ -4,6 +4,7 @@ #include #include + namespace utempl { namespace impl { @@ -29,6 +30,12 @@ template consteval auto operator==(const TypeList& first, const TypeList& second) -> bool { return std::same_as; }; + +template +consteval auto operator+(const TypeList&, const TypeList&) -> TypeList { + return {}; +}; + template consteval auto Get(std::index_sequence, decltype(impl::Caster(Is))..., T, ...) -> T; @@ -52,5 +59,10 @@ template consteval auto Transform(TypeList, auto&& f) -> TypeList{}))...> { return {}; }; +template +consteval auto Filter(TypeList, auto&& f) { + return ([](auto&& list){if constexpr(decltype(f(list))::kValue) {return list;} else {return kTypeList<>;}}(kType) + ...); +}; + } // namespace utempl