insert.cpp 978 B

1234567891011121314151617181920212223242526272829303132
  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. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/insert.hpp>
  6. #include <boost/hana/map.hpp>
  7. #include <boost/hana/pair.hpp>
  8. #include <boost/hana/type.hpp>
  9. #include <string>
  10. namespace hana = boost::hana;
  11. using namespace std::literals;
  12. int main() {
  13. auto m = hana::make_map(
  14. hana::make_pair(hana::type_c<int>, "abcd"s),
  15. hana::make_pair(hana::type_c<void>, 1234)
  16. );
  17. BOOST_HANA_RUNTIME_CHECK(
  18. hana::insert(m, hana::make_pair(hana::type_c<float>, 'x')) ==
  19. hana::make_map(
  20. hana::make_pair(hana::type_c<int>, "abcd"s),
  21. hana::make_pair(hana::type_c<void>, 1234),
  22. hana::make_pair(hana::type_c<float>, 'x')
  23. )
  24. );
  25. BOOST_HANA_RUNTIME_CHECK(hana::insert(m, hana::make_pair(hana::type_c<void>, 'x')) == m);
  26. }