diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 413e35a..9ffe45c 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -472,6 +472,12 @@ using L1 = mp_list, std::ratio<1,4>>; using R1 = mp_sort; // mp_list, ratio<1,2>> ---- +## mp_sort_q + + template using mp_sort_q = mp_sort; + +As `mp_sort`, but takes a quoted metafunction. + ## mp_nth_element_c template class P> using mp_nth_element_c = /*...*/; diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 0f3234e..be94a83 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -516,6 +516,7 @@ template class L, class T1, class... T, template cl } // namespace detail template class P> using mp_sort = typename detail::mp_sort_impl::type; +template using mp_sort_q = mp_sort; // mp_nth_element(_c) namespace detail diff --git a/test/Jamfile b/test/Jamfile index eeb6b3b..eebca65 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -64,6 +64,7 @@ run mp_remove_if_q.cpp ; run mp_partition.cpp ; run mp_partition_q.cpp ; run mp_sort.cpp ; +run mp_sort_q.cpp ; run mp_find.cpp ; run mp_find_if.cpp ; run mp_reverse.cpp ; diff --git a/test/mp_sort_q.cpp b/test/mp_sort_q.cpp new file mode 100644 index 0000000..84f8b45 --- /dev/null +++ b/test/mp_sort_q.cpp @@ -0,0 +1,58 @@ + +// 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 + +using boost::mp11::mp_bool; + +struct Q_sizeof_less +{ + template using fn = mp_bool<(sizeof(T) < sizeof(U))>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_sort_q; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, L1>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list>)); + + using L3 = 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, std::tuple>)); + + using L3 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>)); + } + + return boost::report_errors(); +}