Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
19d1fc6890 | |||
a436935d89 |
@ -244,7 +244,7 @@ namespace meta {
|
|||||||
//! @{
|
//! @{
|
||||||
namespace front_impl {
|
namespace front_impl {
|
||||||
template <typename L>
|
template <typename L>
|
||||||
struct front_ { };
|
struct front_ { using type = nil_; };
|
||||||
|
|
||||||
template <typename Head, typename... Tail>
|
template <typename Head, typename... Tail>
|
||||||
struct front_<typelist<Head, Tail...>> {
|
struct front_<typelist<Head, Tail...>> {
|
||||||
@ -265,7 +265,7 @@ namespace meta {
|
|||||||
//! @{
|
//! @{
|
||||||
namespace back_impl {
|
namespace back_impl {
|
||||||
template <typename List>
|
template <typename List>
|
||||||
struct back_ { };
|
struct back_ { using type = nil_; };
|
||||||
|
|
||||||
template <typename Head, typename... Tail>
|
template <typename Head, typename... Tail>
|
||||||
struct back_<typelist<Head, 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
|
* 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$
|
* 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
|
* 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
|
* starting from that position as new typelist
|
||||||
*
|
*
|
||||||
* Complexity \f$ O(N) \f$
|
* Complexity \f$ O(N) \f$
|
||||||
@ -705,8 +705,21 @@ namespace meta {
|
|||||||
using seek = seek_if <List, same_as<T>>;
|
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>
|
template <typename List, typename Pred>
|
||||||
using first_if = front<seek_if<List, Pred>>;
|
using first_if = front<seek_if<List, Pred>>;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! \name count_if
|
//! \name count_if
|
||||||
//! @{
|
//! @{
|
||||||
@ -783,8 +796,8 @@ namespace meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return a new typelist with elements, the elements of \c List that satisfy the
|
* Returns 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_
|
* invocable \c Pred such that `eval<invoke<Pred, Item>>` yields to \c true_
|
||||||
*
|
*
|
||||||
* Complexity \f$ O(N) \f$
|
* Complexity \f$ O(N) \f$
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
//! @{
|
//! @{
|
||||||
namespace utl {
|
namespace utl {
|
||||||
|
|
||||||
#if !defined __cpp_lib_is_invocable
|
//#if !defined __cpp_lib_is_invocable
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -216,9 +216,10 @@ namespace utl {
|
|||||||
>;
|
>;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
#else
|
//#else
|
||||||
|
//using is_invocable = std::is_invocable;
|
||||||
#endif
|
//
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
@ -19,11 +19,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <gtest/gtest.h>
|
#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);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
std::cout << "Exception: " << e.what() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +174,9 @@ namespace TmetaTypelist {
|
|||||||
EXPECT_EQ (true, (std::is_same<long, at<l, int_<3>>>()));
|
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<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<short, back<l>>()));
|
||||||
|
EXPECT_EQ (true, (std::is_same<nil_, back<typelist<>>>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TmetaTypelist, Concat) {
|
TEST(TmetaTypelist, Concat) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user