diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 5c6b22a..8e651e6 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -541,6 +541,12 @@ is `mp_size`. `mp_find_f` is an alias for `mp_size_t`, where `I` is the zero-based index of the first element `T` in `L` for which `mp_to_bool>` is `mp_true`. If there is no such element, `mp_find_if` is `mp_size`. +## mp_find_if_q + + template using mp_find_if_q = mp_find_if; + +As `mp_find_if`, but takes a quoted metafunction. + ## mp_reverse template using mp_reverse = /*...*/; diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 08680b2..9487767 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -729,6 +729,7 @@ template class L, class T1, class... T, template cl } // namespace detail template class P> using mp_find_if = typename detail::mp_find_if_impl::type; +template using mp_find_if_q = mp_find_if; // mp_reverse namespace detail diff --git a/test/Jamfile b/test/Jamfile index ed2e96c..908457f 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -67,6 +67,7 @@ run mp_sort.cpp ; run mp_sort_q.cpp ; run mp_find.cpp ; run mp_find_if.cpp ; +run mp_find_if_q.cpp ; run mp_reverse.cpp ; run mp_fold.cpp ; run mp_fold_q.cpp ; diff --git a/test/mp_find_if_q.cpp b/test/mp_find_if_q.cpp new file mode 100644 index 0000000..73aaf4a --- /dev/null +++ b/test/mp_find_if_q.cpp @@ -0,0 +1,61 @@ + +// 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 +#include + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_find_if_q; + using boost::mp11::mp_size_t; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<0>>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<3>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<0>>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<3>>)); + } + + { + using L2 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_size_t<1>>)); + } + + return boost::report_errors(); +}