mirror of
https://github.com/boostorg/mp11.git
synced 2025-12-04 15:59:19 +01:00
Improve mp_copy_if, mp_remove(_if), mp_partition
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015-2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -17,6 +18,10 @@ struct X1 {};
|
||||
struct X2 {};
|
||||
struct X3 {};
|
||||
|
||||
using boost::mp11::mp_bool;
|
||||
|
||||
template<class N> using is_odd = mp_bool<N::value % 2 != 0>;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_list;
|
||||
@@ -46,5 +51,17 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_pointer>, std::tuple<X1, X1 const, X2 const>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_size_t;
|
||||
|
||||
{
|
||||
int const N = 12;
|
||||
using L1 = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_remove_if<L1, is_odd>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user