difference.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/difference.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/map.hpp>
  8. #include <boost/hana/string.hpp>
  9. #include <string>
  10. namespace hana = boost::hana;
  11. static auto m1 = hana::make_map(
  12. hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>),
  13. hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<std::string>)
  14. );
  15. static auto m2 = hana::make_map(
  16. hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>),
  17. hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<std::string>),
  18. hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>)
  19. );
  20. static auto m3 = hana::make_map(
  21. hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>),
  22. hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<int>),
  23. hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<long long>)
  24. );
  25. int main() {
  26. BOOST_HANA_CONSTANT_CHECK(hana::difference(m1, m2) == m1);
  27. BOOST_HANA_CONSTANT_CHECK(hana::difference(m1, m3) == hana::make_map());
  28. BOOST_HANA_CONSTANT_CHECK(hana::difference(m3, m1) == hana::make_map(
  29. hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<int>)
  30. ));
  31. BOOST_HANA_CONSTANT_CHECK(hana::difference(m2, m3) == hana::make_map(
  32. hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>),
  33. hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>)
  34. ));
  35. }