• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/integral.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 
main()22 int main()
23 {
24     using boost::mp11::mp_list;
25     using boost::mp11::mp_contains;
26     using boost::mp11::mp_true;
27     using boost::mp11::mp_false;
28 
29     {
30         using L1 = mp_list<>;
31 
32         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L1, void>, mp_false>));
33 
34         using L2 = mp_list<X1, X2, X3, X2, X3, X3>;
35 
36         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, void>, mp_false>));
37         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X1>, mp_true>));
38         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X2>, mp_true>));
39         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X3>, mp_true>));
40     }
41 
42     {
43         using L3 = std::tuple<>;
44 
45         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L3, void>, mp_false>));
46 
47         using L4 = std::tuple<X1, X2, X3, X2, X3, X3>;
48 
49         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, void>, mp_false>));
50         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X1>, mp_true>));
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X2>, mp_true>));
52         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X3>, mp_true>));
53     }
54 
55     {
56         using L5 = std::pair<X1, X2>;
57 
58         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, void>, mp_false>));
59         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, X1>, mp_true>));
60         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, X2>, mp_true>));
61     }
62 
63     return boost::report_errors();
64 }
65