| 1 | |
| 2 | // Copyright 2015-2017 Peter Dimov. |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. |
| 5 | // |
| 6 | // See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt |
| 8 | |
| 9 | |
| 10 | #include <boost/mp11/algorithm.hpp> |
| 11 | #include <boost/mp11/list.hpp> |
| 12 | #include <boost/mp11/integral.hpp> |
| 13 | #include <boost/mp11/bind.hpp> |
| 14 | #include <boost/core/lightweight_test_trait.hpp> |
| 15 | #include <type_traits> |
| 16 | #include <tuple> |
| 17 | |
| 18 | struct X1 {}; |
| 19 | struct X2 {}; |
| 20 | struct X3 {}; |
| 21 | struct X4 {}; |
| 22 | |
| 23 | template<class T1, class T2> struct F {}; |
| 24 | |
| 25 | int main() |
| 26 | { |
| 27 | using boost::mp11::mp_list; |
| 28 | using boost::mp11::mp_reverse_fold_q; |
| 29 | using boost::mp11::mp_quote; |
| 30 | |
| 31 | using Q = mp_quote<F>; |
| 32 | |
| 33 | { |
| 34 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<>, void, Q>, void>)); |
| 35 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1>, void, Q>, F<X1, void>>)); |
| 36 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2>, void, Q>, F<X1, F<X2, void>>>)); |
| 37 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2, X3>, void, Q>, F<X1, F<X2, F<X3, void>>>>)); |
| 38 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2, X3, X4>, void, Q>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); |
| 39 | } |
| 40 | |
| 41 | { |
| 42 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<>, void, Q>, void>)); |
| 43 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1>, void, Q>, F<X1, void>>)); |
| 44 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2>, void, Q>, F<X1, F<X2, void>>>)); |
| 45 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3>, void, Q>, F<X1, F<X2, F<X3, void>>>>)); |
| 46 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, void, Q>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); |
| 47 | } |
| 48 | |
| 49 | using boost::mp11::mp_bind; |
| 50 | using boost::mp11::_1; |
| 51 | using boost::mp11::_2; |
| 52 | |
| 53 | using boost::mp11::mp_push_back; |
| 54 | |
| 55 | { |
| 56 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_bind<mp_push_back, _2, _1>>, mp_list<X4, X3, X2, X1>>)); |
| 57 | } |
| 58 | |
| 59 | using boost::mp11::mp_push_front; |
| 60 | |
| 61 | { |
| 62 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_bind<mp_push_front, _2, _1>>, mp_list<X1, X2, X3, X4>>)); |
| 63 | } |
| 64 | |
| 65 | return boost::report_errors(); |
| 66 | } |
| 67 | |