• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2016, 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/map.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 using boost::mp11::mp_int;
19 
20 template<class T, class U> using inc = mp_int<U::value + 1>;
21 
main()22 int main()
23 {
24     using boost::mp11::mp_map_update;
25     using boost::mp11::mp_list;
26 
27     using M1 = mp_list<>;
28 
29     using M2 = mp_map_update< M1, std::pair<char, mp_int<0>>, inc >;
30     BOOST_TEST_TRAIT_TRUE((std::is_same<M2, mp_list<std::pair<char, mp_int<0>>>>));
31 
32     using M3 = mp_map_update< M2, std::pair<char, mp_int<0>>, inc >;
33     BOOST_TEST_TRAIT_TRUE((std::is_same<M3, mp_list<std::pair<char, mp_int<1>>>>));
34 
35     using M4 = mp_map_update< M3, std::pair<int, mp_int<0>>, inc >;
36     BOOST_TEST_TRAIT_TRUE((std::is_same<M4, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>>>));
37 
38     using M5 = mp_map_update< M4, std::pair<long, mp_int<0>>, inc >;
39     BOOST_TEST_TRAIT_TRUE((std::is_same<M5, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<0>>>>));
40 
41     using M6 = mp_map_update< M5, std::pair<long, mp_int<0>>, inc >;
42     BOOST_TEST_TRAIT_TRUE((std::is_same<M6, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>));
43 
44     using M7 = mp_map_update< M6, std::pair<char, mp_int<0>>, inc >;
45     BOOST_TEST_TRAIT_TRUE((std::is_same<M7, mp_list<std::pair<char, mp_int<2>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>));
46 
47     return boost::report_errors();
48 }
49