From a436935d8999ea799876fb9afd01a997e1bb1224 Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Thu, 8 Oct 2020 21:51:23 +0300 Subject: [PATCH] WIP: concepts rework --- include/utl/meta/typelist.h | 23 ++++++++++++++++++----- test/tests/TmetaTypelist.cpp | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/utl/meta/typelist.h b/include/utl/meta/typelist.h index 6e62651..6a1c4d6 100644 --- a/include/utl/meta/typelist.h +++ b/include/utl/meta/typelist.h @@ -244,7 +244,7 @@ namespace meta { //! @{ namespace front_impl { template - struct front_ { }; + struct front_ { using type = nil_; }; template struct front_> { @@ -636,7 +636,7 @@ namespace meta { /*! * Search for the first \c Item on the \c List for which the predicate \c Pred - * returns true_ when `eval>` + * yields to \c true_ when `eval>` * * Complexity \f$ O(N) \f$ * @@ -684,7 +684,7 @@ namespace meta { /*! * Search for the first \c Item on the \c List for which the predicate \c Pred - * returns true_ when `eval>` and return the rest of the \c List + * yields to \c true_ when `eval>` and return the rest of the \c List * starting from that position as new typelist * * Complexity \f$ O(N) \f$ @@ -705,8 +705,21 @@ namespace meta { using seek = seek_if >; //! @} + //! \name first_if + //! @{ + /*! + * Search and returns the first \c Item on the \c List for which the predicate \c Pred + * yields to true_ when \code eval> \endcode + * + * Complexity \f$ O(N) \f$ + * + * \tparam List A typelist + * \tparam Pred A Unary invocable predicate + * \return On success the item, otherwise utl::meta::nil_ + */ template using first_if = front>; + //! @} //! \name count_if //! @{ @@ -783,8 +796,8 @@ namespace meta { } /*! - * Return a new typelist with elements, the elements of \c List that satisfy the - * invocable \c Pred such that `eval>` is \c true_ + * Returns a new typelist with elements, the elements of \c List that satisfy the + * invocable \c Pred such that `eval>` yields to \c true_ * * Complexity \f$ O(N) \f$ * diff --git a/test/tests/TmetaTypelist.cpp b/test/tests/TmetaTypelist.cpp index 28b5053..0f55a20 100644 --- a/test/tests/TmetaTypelist.cpp +++ b/test/tests/TmetaTypelist.cpp @@ -174,7 +174,9 @@ namespace TmetaTypelist { EXPECT_EQ (true, (std::is_same>>())); EXPECT_EQ (true, (std::is_same>())); + EXPECT_EQ (true, (std::is_same>>())); EXPECT_EQ (true, (std::is_same>())); + EXPECT_EQ (true, (std::is_same>>())); } TEST(TmetaTypelist, Concat) {