Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / example / map / insert.cpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/insert.hpp>
7 #include <boost/hana/map.hpp>
8 #include <boost/hana/pair.hpp>
9 #include <boost/hana/type.hpp>
10
11 #include <string>
12 namespace hana = boost::hana;
13 using namespace std::literals;
14
15
16 int main() {
17     auto m = hana::make_map(
18         hana::make_pair(hana::type_c<int>, "abcd"s),
19         hana::make_pair(hana::type_c<void>, 1234)
20     );
21
22     BOOST_HANA_RUNTIME_CHECK(
23         hana::insert(m, hana::make_pair(hana::type_c<float>, 'x')) ==
24         hana::make_map(
25             hana::make_pair(hana::type_c<int>, "abcd"s),
26             hana::make_pair(hana::type_c<void>, 1234),
27             hana::make_pair(hana::type_c<float>, 'x')
28         )
29     );
30
31     BOOST_HANA_RUNTIME_CHECK(hana::insert(m, hana::make_pair(hana::type_c<void>, 'x')) == m);
32 }