• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 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/bind.hpp>
11 #include <boost/mp11/list.hpp>
12 #include <boost/mp11/algorithm.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 struct X4 {};
22 struct X5 {};
23 struct X6 {};
24 struct X7 {};
25 struct X8 {};
26 struct X9 {};
27 
28 template<class T> using add_pointer = T*;
29 
main()30 int main()
31 {
32     using namespace boost::mp11;
33 
34     BOOST_TEST_TRAIT_TRUE((std::is_same<_1::fn<X1>, X1>));
35     BOOST_TEST_TRAIT_TRUE((std::is_same<_1::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X1>));
36 
37     BOOST_TEST_TRAIT_TRUE((std::is_same<_2::fn<X1, X2>, X2>));
38     BOOST_TEST_TRAIT_TRUE((std::is_same<_2::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X2>));
39 
40     BOOST_TEST_TRAIT_TRUE((std::is_same<_3::fn<X1, X2, X3>, X3>));
41     BOOST_TEST_TRAIT_TRUE((std::is_same<_3::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X3>));
42 
43     BOOST_TEST_TRAIT_TRUE((std::is_same<_4::fn<X1, X2, X3, X4>, X4>));
44     BOOST_TEST_TRAIT_TRUE((std::is_same<_4::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X4>));
45 
46     BOOST_TEST_TRAIT_TRUE((std::is_same<_5::fn<X1, X2, X3, X4, X5>, X5>));
47     BOOST_TEST_TRAIT_TRUE((std::is_same<_5::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X5>));
48 
49     BOOST_TEST_TRAIT_TRUE((std::is_same<_6::fn<X1, X2, X3, X4, X5, X6>, X6>));
50     BOOST_TEST_TRAIT_TRUE((std::is_same<_6::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X6>));
51 
52     BOOST_TEST_TRAIT_TRUE((std::is_same<_7::fn<X1, X2, X3, X4, X5, X6, X7>, X7>));
53     BOOST_TEST_TRAIT_TRUE((std::is_same<_7::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X7>));
54 
55     BOOST_TEST_TRAIT_TRUE((std::is_same<_8::fn<X1, X2, X3, X4, X5, X6, X7, X8>, X8>));
56     BOOST_TEST_TRAIT_TRUE((std::is_same<_8::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X8>));
57 
58     BOOST_TEST_TRAIT_TRUE((std::is_same<_9::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X9>));
59 
60     //
61 
62     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _1>::fn<X1>, X1*>));
63     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _1>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X1*>));
64 
65     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _2>::fn<X1, X2>, X2*>));
66     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _2>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X2*>));
67 
68     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _3>::fn<X1, X2, X3>, X3*>));
69     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _3>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X3*>));
70 
71     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _4>::fn<X1, X2, X3, X4>, X4*>));
72     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _4>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X4*>));
73 
74     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _5>::fn<X1, X2, X3, X4, X5>, X5*>));
75     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _5>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X5*>));
76 
77     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _6>::fn<X1, X2, X3, X4, X5, X6>, X6*>));
78     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _6>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X6*>));
79 
80     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _7>::fn<X1, X2, X3, X4, X5, X6, X7>, X7*>));
81     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _7>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X7*>));
82 
83     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8>, X8*>));
84     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X8*>));
85 
86     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _9>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X9*>));
87 
88     //
89 
90     BOOST_TEST_TRAIT_TRUE((std::is_same<
91         mp_bind<std::tuple,
92             mp_bind<add_pointer, _9>,
93             mp_bind<add_pointer, _8>,
94             mp_bind<add_pointer, _7>,
95             mp_bind<add_pointer, _6>,
96             mp_bind<add_pointer, _5>,
97             mp_bind<add_pointer, _4>,
98             mp_bind<add_pointer, _3>,
99             mp_bind<add_pointer, _2>,
100             mp_bind<add_pointer, _1>
101         >::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, std::tuple<X9*, X8*, X7*, X6*, X5*, X4*, X3*, X2*, X1*>>));
102 
103     //
104 
105     return boost::report_errors();
106 }
107