take.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/detail/variadic/take.hpp>
  5. #include <boost/hana/assert.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <laws/base.hpp>
  8. namespace hana = boost::hana;
  9. namespace vd = hana::detail::variadic;
  10. using hana::test::ct_eq;
  11. int main() {
  12. hana::test::_injection<0> f{};
  13. {
  14. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  15. vd::take<0>()(f),
  16. f()
  17. ));
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. vd::take<0>(ct_eq<1>{})(f),
  20. f()
  21. ));
  22. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  23. vd::take<0>(ct_eq<1>{}, ct_eq<2>{})(f),
  24. f()
  25. ));
  26. }
  27. {
  28. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  29. vd::take<1>(ct_eq<1>{})(f),
  30. f(ct_eq<1>{})
  31. ));
  32. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  33. vd::take<1>(ct_eq<1>{}, ct_eq<2>{})(f),
  34. f(ct_eq<1>{})
  35. ));
  36. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  37. vd::take<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})(f),
  38. f(ct_eq<1>{})
  39. ));
  40. }
  41. {
  42. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  43. vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{})(f),
  44. f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{})
  45. ));
  46. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  47. vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{})(f),
  48. f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{})
  49. ));
  50. }
  51. }