erase_key.cpp 1005 B

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