unpack.cpp 984 B

12345678910111213141516171819202122232425262728293031323334
  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/experimental/view.hpp>
  7. #include <boost/hana/unpack.hpp>
  8. #include <laws/base.hpp>
  9. #include <support/seq.hpp>
  10. namespace hana = boost::hana;
  11. using hana::test::ct_eq;
  12. int main() {
  13. auto f = hana::test::_injection<0>{};
  14. auto g = hana::test::_injection<1>{};
  15. auto check = [=](auto ...x) {
  16. auto storage = ::seq(x...);
  17. auto transformed = hana::experimental::transformed(storage, f);
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. hana::unpack(transformed, g),
  20. g(f(x)...)
  21. ));
  22. };
  23. check();
  24. check(ct_eq<0>{});
  25. check(ct_eq<0>{}, ct_eq<1>{});
  26. check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
  27. check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{});
  28. }