reverse.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef BOOST_HANA_TEST_AUTO_REVERSE_HPP
  5. #define BOOST_HANA_TEST_AUTO_REVERSE_HPP
  6. #include <boost/hana/assert.hpp>
  7. #include <boost/hana/equal.hpp>
  8. #include <boost/hana/reverse.hpp>
  9. #include "test_case.hpp"
  10. #include <laws/base.hpp>
  11. TestCase test_reverse{[]{
  12. namespace hana = boost::hana;
  13. using hana::test::ct_eq;
  14. using hana::test::cx_eq;
  15. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  16. hana::reverse(MAKE_TUPLE()),
  17. MAKE_TUPLE()
  18. ));
  19. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  20. hana::reverse(MAKE_TUPLE(ct_eq<0>{})),
  21. MAKE_TUPLE(ct_eq<0>{})
  22. ));
  23. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  24. hana::reverse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})),
  25. MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{})
  26. ));
  27. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  28. hana::reverse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
  29. MAKE_TUPLE(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{})
  30. ));
  31. #ifndef MAKE_TUPLE_NO_CONSTEXPR
  32. static_assert(hana::equal(
  33. hana::reverse(MAKE_TUPLE(cx_eq<1>{})),
  34. MAKE_TUPLE(cx_eq<1>{})
  35. ), "");
  36. static_assert(hana::equal(
  37. hana::reverse(MAKE_TUPLE(cx_eq<1>{}, cx_eq<2>{})),
  38. MAKE_TUPLE(cx_eq<2>{}, cx_eq<1>{})
  39. ), "");
  40. static_assert(hana::equal(
  41. hana::reverse(MAKE_TUPLE(cx_eq<1>{}, cx_eq<2>{}, cx_eq<3>{})),
  42. MAKE_TUPLE(cx_eq<3>{}, cx_eq<2>{}, cx_eq<1>{})
  43. ), "");
  44. #endif
  45. }};
  46. #endif // !BOOST_HANA_TEST_AUTO_REVERSE_HPP