Compare commits

...

2 Commits

Author SHA1 Message Date
19d1fc6890 WIP: invoke c++17 rework 2021-10-04 21:13:30 +03:00
a436935d89 WIP: concepts rework 2020-10-08 21:51:23 +03:00
4 changed files with 31 additions and 12 deletions

View File

@ -244,7 +244,7 @@ namespace meta {
//! @{
namespace front_impl {
template <typename L>
struct front_ { };
struct front_ { using type = nil_; };
template <typename Head, typename... Tail>
struct front_<typelist<Head, Tail...>> {
@ -265,7 +265,7 @@ namespace meta {
//! @{
namespace back_impl {
template <typename List>
struct back_ { };
struct back_ { using type = nil_; };
template <typename Head, typename... Tail>
struct back_<typelist<Head, Tail...>> {
@ -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<invoke<Pred, Item>>`
* yields to \c true_ when `eval<invoke<Pred, Item>>`
*
* 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<invoke<Pred, Item>>` and return the rest of the \c List
* yields to \c true_ when `eval<invoke<Pred, Item>>` 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 <List, same_as<T>>;
//! @}
//! \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<invoke<Pred, Item>> \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 <typename List, typename Pred>
using first_if = front<seek_if<List, Pred>>;
//! @}
//! \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<invoke<Pred, Item>>` is \c true_
* Returns a new typelist with elements, the elements of \c List that satisfy the
* invocable \c Pred such that `eval<invoke<Pred, Item>>` yields to \c true_
*
* Complexity \f$ O(N) \f$
*

View File

@ -21,7 +21,7 @@
//! @{
namespace utl {
#if !defined __cpp_lib_is_invocable
//#if !defined __cpp_lib_is_invocable
namespace detail {
template <class T>
@ -216,9 +216,10 @@ namespace utl {
>;
//! @}
#else
#endif
//#else
//using is_invocable = std::is_invocable;
//
//#endif
}
//! @}

View File

@ -19,11 +19,14 @@
*
*/
#include <gtest/gtest.h>
#include <exception>
GTEST_API_ int main(int argc, char **argv) {
GTEST_API_ int main(int argc, char **argv) try {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what() << '\n';
}

View File

@ -174,7 +174,9 @@ namespace TmetaTypelist {
EXPECT_EQ (true, (std::is_same<long, at<l, int_<3>>>()));
EXPECT_EQ (true, (std::is_same<char*, front<l>>()));
EXPECT_EQ (true, (std::is_same<nil_, front<typelist<>>>()));
EXPECT_EQ (true, (std::is_same<short, back<l>>()));
EXPECT_EQ (true, (std::is_same<nil_, back<typelist<>>>()));
}
TEST(TmetaTypelist, Concat) {