• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2016 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/map.hpp>
11 #include <boost/mp11/list.hpp>
12 #include <boost/core/lightweight_test_trait.hpp>
13 #include <type_traits>
14 #include <tuple>
15 #include <utility>
16 
main()17 int main()
18 {
19     using boost::mp11::mp_map_insert;
20     using boost::mp11::mp_list;
21     using boost::mp11::mp_push_back;
22 
23     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<mp_list<>, mp_list<void>>, mp_list<mp_list<void>>>));
24     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::tuple<int>>, std::tuple<std::tuple<int>>>));
25     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::pair<int, float>>, std::tuple<std::pair<int, float>>>));
26 
27     {
28         using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>;
29 
30         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
31         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
32         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>));
33         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
34     }
35 
36     {
37         using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>;
38 
39         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
40         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
41         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>));
42         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
43     }
44 
45     {
46         using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>;
47 
48         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
49         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
50         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>));
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
52         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>));
53     }
54 
55     {
56         using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>;
57 
58         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
59         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
60         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>));
61         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
62         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>));
63     }
64 
65     return boost::report_errors();
66 }
67