drop_into.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/drop_into.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. struct non_pod { virtual ~non_pod() { } };
  12. int main() {
  13. hana::test::_injection<0> f{};
  14. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  15. vd::drop_into<0>(f)(),
  16. f()
  17. ));
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. vd::drop_into<0>(f)(ct_eq<0>{}),
  20. f(ct_eq<0>{})
  21. ));
  22. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  23. vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}),
  24. f(ct_eq<0>{}, ct_eq<1>{})
  25. ));
  26. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  27. vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
  28. f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
  29. ));
  30. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  31. vd::drop_into<1>(f)(ct_eq<0>{}),
  32. f()
  33. ));
  34. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  35. vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}),
  36. f(ct_eq<1>{})
  37. ));
  38. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  39. vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
  40. f(ct_eq<1>{}, ct_eq<2>{})
  41. ));
  42. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  43. vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}),
  44. f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})
  45. ));
  46. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  47. vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}),
  48. f()
  49. ));
  50. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  51. vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
  52. f(ct_eq<2>{})
  53. ));
  54. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  55. vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}),
  56. f(ct_eq<2>{}, ct_eq<3>{})
  57. ));
  58. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  59. vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}),
  60. f(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{})
  61. ));
  62. // make sure we can use non-pods
  63. vd::drop_into<1>(f)(ct_eq<0>{}, non_pod{});
  64. vd::drop_into<1>(f)(non_pod{}, ct_eq<1>{});
  65. }