1
2 // Copyright 2015 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/utility.hpp>
13 #include <boost/core/lightweight_test_trait.hpp>
14 #include <type_traits>
15 #include <tuple>
16 #include <utility>
17
18 struct X1 {};
19 struct X2 {};
20 struct X3 {};
21
22 struct Y1 {};
23
24 struct Z1 {};
25 struct Z2 {};
26
27 template<class T> struct F1 {};
28 template<class T1, class T2, class T3> struct F3 {};
29
30 template<class...> struct F {};
31
main()32 int main()
33 {
34 using boost::mp11::mp_list;
35 using boost::mp11::mp_product;
36 using boost::mp11::mp_product_q;
37 using boost::mp11::mp_quote;
38
39 {
40 using L1 = std::tuple<X1, X2, X3>;
41 using L2 = mp_list<Y1>;
42 using L3 = std::pair<Z1, Z2>;
43
44 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F3, L1, L2, L3>, std::tuple<F3<X1, Y1, Z1>, F3<X1, Y1, Z2>, F3<X2, Y1, Z1>, F3<X2, Y1, Z2>, F3<X3, Y1, Z1>, F3<X3, Y1, Z2>>>));
45 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F3>, L1, L2, L3>, std::tuple<F3<X1, Y1, Z1>, F3<X1, Y1, Z2>, F3<X2, Y1, Z1>, F3<X2, Y1, Z2>, F3<X3, Y1, Z1>, F3<X3, Y1, Z2>>>));
46 }
47
48 {
49 using L1 = std::tuple<X1, X2, X3>;
50 using L2 = mp_list<>;
51 using L3 = std::pair<Z1, Z2>;
52
53 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F3, L1, L2, L3>, std::tuple<>>));
54 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F3>, L1, L2, L3>, std::tuple<>>));
55 }
56
57 {
58 using L1 = std::tuple<X1, X2, X3>;
59 using L2 = mp_list<X1, X2, X3>;
60
61 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F1, L1>, std::tuple<F1<X1>, F1<X2>, F1<X3>>>));
62 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F1>, L1>, std::tuple<F1<X1>, F1<X2>, F1<X3>>>));
63
64 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F1, L2>, mp_list<F1<X1>, F1<X2>, F1<X3>>>));
65 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F1>, L2>, mp_list<F1<X1>, F1<X2>, F1<X3>>>));
66 }
67
68 {
69 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F>, mp_list<F<>>>));
70 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F>>, mp_list<F<>>>));
71 }
72
73 return boost::report_errors();
74 }
75