diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 240b40d..a30441e 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -439,6 +439,12 @@ Removes all `V` elements of `L` and returns the result. Removes all elements `T` of `L` for which `mp_to_bool>` is `mp_true` and returns the result. +## mp_remove_if_q + + template using mp_remove_if_q = mp_remove_if; + +As `mp_remove_if`, but takes a quoted metafunction. + ## mp_partition template class P> using mp_partition = /*...*/; diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 6c22a39..ac600ff 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -455,6 +455,7 @@ template class L, class... T, template class P> str } // namespace detail template class P> using mp_remove_if = typename detail::mp_remove_if_impl::type; +template using mp_remove_if_q = mp_remove_if; // mp_partition namespace detail diff --git a/test/Jamfile b/test/Jamfile index 2176b09..72a9113 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -60,6 +60,7 @@ run mp_copy_if.cpp ; run mp_copy_if_q.cpp ; run mp_remove.cpp ; run mp_remove_if.cpp ; +run mp_remove_if_q.cpp ; run mp_partition.cpp ; run mp_sort.cpp ; run mp_find.cpp ; diff --git a/test/mp_remove_if.cpp b/test/mp_remove_if.cpp index bd9b777..883bf6c 100644 --- a/test/mp_remove_if.cpp +++ b/test/mp_remove_if.cpp @@ -51,10 +51,10 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>)); } - using boost::mp11::mp_iota_c; - using boost::mp11::mp_size_t; + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; - { + { int const N = 12; using L1 = mp_iota_c; diff --git a/test/mp_remove_if_q.cpp b/test/mp_remove_if_q.cpp new file mode 100644 index 0000000..818cc63 --- /dev/null +++ b/test/mp_remove_if_q.cpp @@ -0,0 +1,72 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + + +#include +#include +#include +#include +#include +#include +#include + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +using boost::mp11::mp_bool; + +struct Q_is_odd +{ + template using fn = mp_bool; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_remove_if_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, L1>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, L1>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c; + + using R1 = mp_remove_if_q; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + + return boost::report_errors(); +}