keys.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/concept/struct.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/keys.hpp>
  9. #include "minimal_struct.hpp"
  10. #include <laws/base.hpp>
  11. #include <support/seq.hpp>
  12. namespace hana = boost::hana;
  13. using hana::test::ct_eq;
  14. template <int i = 0>
  15. struct undefined { };
  16. int main() {
  17. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  18. hana::keys(obj()),
  19. ::seq()
  20. ));
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  22. hana::keys(obj(undefined<0>{})),
  23. ::seq(hana::int_c<0>)
  24. ));
  25. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  26. hana::keys(obj(undefined<0>{}, undefined<1>{})),
  27. ::seq(hana::int_c<0>, hana::int_c<1>)
  28. ));
  29. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  30. hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{})),
  31. ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  34. hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{}, undefined<3>{})),
  35. ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>, hana::int_c<3>)
  36. ));
  37. }