diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index a30441e..413e35a 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -452,6 +452,12 @@ As `mp_remove_if`, but takes a quoted metafunction. `mp_partition, P>` partitions `L` into two lists `L` and `L` such that `mp_to_bool>` is `mp_true` for the elements of `L` and `mp_false` for the elements of `L`. Returns `L, L>`. +## mp_partition_q + + template using mp_partition_q = mp_partition; + +As `mp_partition`, but takes a quoted metafunction. + ## mp_sort template class P> using mp_sort = /*...*/; diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index ac600ff..0f3234e 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -471,6 +471,7 @@ template class L, class... T, template class P> str } // namespace detail template class P> using mp_partition = typename detail::mp_partition_impl::type; +template using mp_partition_q = mp_partition; // mp_sort namespace detail diff --git a/test/Jamfile b/test/Jamfile index 72a9113..eeb6b3b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -62,6 +62,7 @@ run mp_remove.cpp ; run mp_remove_if.cpp ; run mp_remove_if_q.cpp ; run mp_partition.cpp ; +run mp_partition_q.cpp ; run mp_sort.cpp ; run mp_find.cpp ; run mp_find_if.cpp ; diff --git a/test/mp_partition_q.cpp b/test/mp_partition_q.cpp new file mode 100644 index 0000000..fc04c52 --- /dev/null +++ b/test/mp_partition_q.cpp @@ -0,0 +1,52 @@ + +// 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 + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_partition_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list, mp_list>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple, std::tuple>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, std::tuple, std::tuple>>)); + } + + return boost::report_errors(); +}