unpack.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/equal.hpp>
  6. #include <boost/hana/ext/std/integer_sequence.hpp>
  7. #include <boost/hana/ext/std/integral_constant.hpp>
  8. #include <boost/hana/unpack.hpp>
  9. #include <laws/base.hpp>
  10. #include <type_traits>
  11. #include <utility>
  12. namespace hana = boost::hana;
  13. int main() {
  14. hana::test::_injection<0> f{};
  15. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  16. hana::unpack(std::integer_sequence<int>{}, f),
  17. f()
  18. ));
  19. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  20. hana::unpack(std::integer_sequence<int, 0>{}, f),
  21. f(std::integral_constant<int, 0>{})
  22. ));
  23. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  24. hana::unpack(std::integer_sequence<int, 0, 1>{}, f),
  25. f(std::integral_constant<int, 0>{}, std::integral_constant<int, 1>{})
  26. ));
  27. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  28. hana::unpack(std::integer_sequence<int, 0, 1, 2>{}, f),
  29. f(std::integral_constant<int, 0>{}, std::integral_constant<int, 1>{},
  30. std::integral_constant<int, 2>{})
  31. ));
  32. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  33. hana::unpack(std::integer_sequence<int, 0, 1, 2, 3>{}, f),
  34. f(std::integral_constant<int, 0>{}, std::integral_constant<int, 1>{},
  35. std::integral_constant<int, 2>{}, std::integral_constant<int, 3>{})
  36. ));
  37. }