permutations.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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/all_of.hpp>
  5. #include <boost/hana/assert.hpp>
  6. #include <boost/hana/config.hpp>
  7. #include <boost/hana/contains.hpp>
  8. #include <boost/hana/functional/curry.hpp>
  9. #include <boost/hana/permutations.hpp>
  10. #include <boost/hana/tuple.hpp>
  11. namespace hana = boost::hana;
  12. BOOST_HANA_CONSTEXPR_LAMBDA auto is_permutation_of = hana::curry<2>([](auto xs, auto perm) {
  13. return hana::contains(hana::permutations(xs), perm);
  14. });
  15. int main() {
  16. BOOST_HANA_CONSTEXPR_CHECK(
  17. hana::all_of(
  18. hana::make_tuple(
  19. hana::make_tuple('1', 2, 3.0),
  20. hana::make_tuple('1', 3.0, 2),
  21. hana::make_tuple(2, '1', 3.0),
  22. hana::make_tuple(2, 3.0, '1'),
  23. hana::make_tuple(3.0, '1', 2),
  24. hana::make_tuple(3.0, 2, '1')
  25. ),
  26. is_permutation_of(hana::make_tuple('1', 2, 3.0))
  27. )
  28. );
  29. }