diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 6aa718c..629583b 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -484,6 +484,13 @@ using L1 = mp_list, std::ratio<1,4>, std::ratio<1,2>>; using R1 = mp_fold, std::ratio_add>; // std::ratio<7,8> ---- +## mp_fold_q + + template using mp_fold_q = + mp_fold; + +As `mp_fold`, but takes a quoted metafunction. + ## mp_reverse_fold template class F> using mp_reverse_fold = @@ -491,6 +498,13 @@ using R1 = mp_fold, std::ratio_add>; // std::ratio<7,8> `mp_reverse_fold, V, F>` is `F>>>`, or `V`, if `L` is empty. +## mp_reverse_fold_q + + template using mp_reverse_fold_q = + mp_reverse_fold; + +As `mp_reverse_fold`, but takes a quoted metafunction. + ## mp_unique template using mp_unique = /*...*/; diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 557706a..f8215b7 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -38,6 +38,7 @@ template class F> struct mp_fold_impl; } // namespace detail template class F> using mp_fold = typename detail::mp_fold_impl::type; +template using mp_fold_q = mp_fold; // mp_transform namespace detail @@ -838,6 +839,7 @@ template class L, class T1, class T2, class T3, class T4, cla } // namespace detail template class F> using mp_reverse_fold = typename detail::mp_reverse_fold_impl::type; +template using mp_reverse_fold_q = mp_reverse_fold; // mp_unique namespace detail diff --git a/test/Jamfile b/test/Jamfile index c1ed138..812429f 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -63,7 +63,9 @@ run mp_find.cpp ; run mp_find_if.cpp ; run mp_reverse.cpp ; run mp_fold.cpp ; +run mp_fold_q.cpp ; run mp_reverse_fold.cpp ; +run mp_reverse_fold_q.cpp ; run mp_unique.cpp ; run mp_all_of.cpp ; run mp_any_of.cpp ; diff --git a/test/mp_fold_q.cpp b/test/mp_fold_q.cpp new file mode 100644 index 0000000..475cf08 --- /dev/null +++ b/test/mp_fold_q.cpp @@ -0,0 +1,62 @@ + +// 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 {}; +struct X4 {}; + +template struct F {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_fold_q; + using boost::mp11::mp_quote; + + using Q = mp_quote; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>, X3>, X4>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F, X2>, X3>, X4>>)); + } + + using boost::mp11::mp_push_back; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>, mp_quote>, mp_list>)); + } + + using boost::mp11::mp_push_front; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>, mp_quote>, mp_list>)); + } + + return boost::report_errors(); +} diff --git a/test/mp_reverse_fold_q.cpp b/test/mp_reverse_fold_q.cpp new file mode 100644 index 0000000..09071a8 --- /dev/null +++ b/test/mp_reverse_fold_q.cpp @@ -0,0 +1,66 @@ + +// 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 {}; +struct X4 {}; + +template struct F {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_reverse_fold_q; + using boost::mp11::mp_quote; + + using Q = mp_quote; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, void, Q>, F>>>>)); + } + + using boost::mp11::mp_bind; + using boost::mp11::_1; + using boost::mp11::_2; + + using boost::mp11::mp_push_back; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>, mp_bind>, mp_list>)); + } + + using boost::mp11::mp_push_front; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>, mp_bind>, mp_list>)); + } + + return boost::report_errors(); +}