unpack.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/unpack.hpp>
  9. #include "minimal_struct.hpp"
  10. #include <laws/base.hpp>
  11. #include <support/minimal_product.hpp>
  12. namespace hana = boost::hana;
  13. using hana::test::ct_eq;
  14. int main() {
  15. constexpr auto pair = ::minimal_product;
  16. hana::test::_injection<0> f{};
  17. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  18. hana::unpack(obj(), f),
  19. f()
  20. ));
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  22. hana::unpack(obj(ct_eq<0>{}), f),
  23. f(pair(hana::int_c<0>, ct_eq<0>{}))
  24. ));
  25. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  26. hana::unpack(obj(ct_eq<0>{}, ct_eq<1>{}), f),
  27. f(pair(hana::int_c<0>, ct_eq<0>{}),
  28. pair(hana::int_c<1>, ct_eq<1>{}))
  29. ));
  30. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  31. hana::unpack(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f),
  32. f(pair(hana::int_c<0>, ct_eq<0>{}),
  33. pair(hana::int_c<1>, ct_eq<1>{}),
  34. pair(hana::int_c<2>, ct_eq<2>{}))
  35. ));
  36. }