From 6a21ea68bb9e2c4941cbb0fb2f8c702cafa79f0c Mon Sep 17 00:00:00 2001 From: sha512sum Date: Thu, 14 Mar 2024 01:26:47 +0000 Subject: [PATCH] Fix Find function for 0 size typelists --- include/utempl/type_list.hpp | 12 ++++++++++-- include/utempl/utils.hpp | 6 ------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/utempl/type_list.hpp b/include/utempl/type_list.hpp index 87c3bbe..70573c4 100644 --- a/include/utempl/type_list.hpp +++ b/include/utempl/type_list.hpp @@ -2,6 +2,7 @@ #include #include #include +#include #include @@ -30,6 +31,13 @@ inline constexpr auto kType = TypeList{}; template inline constexpr auto kTypeList = TypeList{}; +template +concept IsTypeList = Overloaded( + [](TypeList>) {return true;}, + [](auto&&) {return false;} +)(kType>); + + template consteval auto operator==(const TypeList& first, const TypeList& second) -> bool { @@ -49,7 +57,7 @@ consteval auto Get(const TypeList&) -> decltype(Get(std::make_index_seque template consteval auto Find(TypeList) -> std::size_t { - std::array arr{std::same_as...}; + std::array arr{std::same_as...}; return std::ranges::find(arr, true) - arr.begin(); }; @@ -65,7 +73,7 @@ consteval auto Transform(TypeList, auto&& f) -> TypeList -consteval auto Filter(TypeList, auto&& f) { +consteval auto FilterTypeList(TypeList, auto&& f) { return ( (kTypeList<> + [](auto&& list) { diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index 2d7343b..7e6b2cb 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -139,12 +139,6 @@ struct IsSafeTuple(std::move(Get<0>(Tuple{MakeTuple(0, k template concept TupleLike = requires{Get<0>(MakeTuple(42));} && impl::IsSafeTuple::value; -template -concept IsTypeList = Overloaded( - [](TypeList>) {return true;}, - [](auto&&) {return false;} -)(kType>); - template inline constexpr auto Transform(Tuple&& container, auto&& f) {