values.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/contains.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/map.hpp>
  8. #include <boost/hana/permutations.hpp>
  9. #include <laws/base.hpp>
  10. #include <support/minimal_product.hpp>
  11. #include <support/seq.hpp>
  12. namespace hana = boost::hana;
  13. template <int i>
  14. auto key() { return hana::test::ct_eq<i>{}; }
  15. template <int i>
  16. auto val() { return hana::test::ct_eq<-i>{}; }
  17. template <int i, int j>
  18. auto p() { return ::minimal_product(key<i>(), val<j>()); }
  19. int main() {
  20. constexpr auto list = ::seq;
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  22. hana::values(hana::make_map()),
  23. list()
  24. ));
  25. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  26. hana::values(hana::make_map(p<1, 1>())),
  27. list(val<1>())
  28. ));
  29. BOOST_HANA_CONSTANT_CHECK(hana::contains(
  30. hana::permutations(list(val<1>(), val<2>())),
  31. hana::values(hana::make_map(p<1, 1>(), p<2, 2>()))
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::contains(
  34. hana::permutations(list(val<1>(), val<2>(), val<3>())),
  35. hana::values(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()))
  36. ));
  37. }