1
0
forked from boostorg/mp11

Update mp_pairwise_fold_q test and example

This commit is contained in:
Peter Dimov
2020-10-17 16:54:06 +03:00
parent 28a736954f
commit 727ecfc0cf
2 changed files with 5 additions and 5 deletions

View File

@@ -767,8 +767,8 @@ As `mp_pairwise_fold`, but takes a quoted metafunction.
.Using mp_pairwise_fold_q
----
template<class L> using is_nondecreasing = mp_none_of<
mp_pairwise_fold_q<L, mp_bind<mp_less, _2, _1>>, mp_to_bool>;
template<class L, template<class...> class P> using is_sorted =
mp_none_of<mp_pairwise_fold_q<L, mp_bind<P, _2, _1>>, mp_to_bool>;
----
## mp_iterate<V, F, R>

View File

@@ -7,12 +7,12 @@
using namespace boost::mp11;
template<class L> using is_sorted = mp_none_of<mp_pairwise_fold_q<L, mp_bind<mp_less, _2, _1>>, mp_to_bool>;
template<class L, template<class...> class P> using is_sorted = mp_none_of<mp_pairwise_fold_q<L, mp_bind<P, _2, _1>>, mp_to_bool>;
int main()
{
BOOST_TEST_TRAIT_TRUE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<7>>>));
BOOST_TEST_TRAIT_FALSE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<2>>>));
BOOST_TEST_TRAIT_TRUE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<7>>, mp_less>));
BOOST_TEST_TRAIT_FALSE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<2>>, mp_less>));
return boost::report_errors();
}