unpack.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/permutations.hpp>
  7. #include <boost/hana/set.hpp>
  8. #include <boost/hana/transform.hpp>
  9. #include <boost/hana/tuple.hpp>
  10. #include <boost/hana/unpack.hpp>
  11. #include <laws/base.hpp>
  12. namespace hana = boost::hana;
  13. using hana::test::ct_eq;
  14. int main() {
  15. hana::test::_injection<0> f{};
  16. auto check = [=](auto ...xs) {
  17. auto arg_perms = hana::permutations(hana::make_tuple(xs...));
  18. auto possible_results = hana::transform(arg_perms, [=](auto args) {
  19. return hana::unpack(args, f);
  20. });
  21. BOOST_HANA_CONSTANT_CHECK(hana::contains(
  22. possible_results,
  23. hana::unpack(hana::make_set(xs...), f)
  24. ));
  25. };
  26. check();
  27. check(ct_eq<1>{});
  28. check(ct_eq<1>{}, ct_eq<2>{});
  29. check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{});
  30. check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{});
  31. }