unfold_right.cpp 851 B

12345678910111213141516171819202122232425262728
  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/equal.hpp>
  6. #include <boost/hana/if.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/minus.hpp>
  9. #include <boost/hana/optional.hpp>
  10. #include <boost/hana/pair.hpp>
  11. #include <boost/hana/tuple.hpp>
  12. #include <boost/hana/unfold_right.hpp>
  13. namespace hana = boost::hana;
  14. BOOST_HANA_CONSTANT_CHECK(
  15. hana::unfold_right<hana::tuple_tag>(hana::int_c<10>, [](auto x) {
  16. return hana::if_(x == hana::int_c<0>,
  17. hana::nothing,
  18. hana::just(hana::make_pair(x, x - hana::int_c<1>))
  19. );
  20. })
  21. ==
  22. hana::tuple_c<int, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1>
  23. );
  24. int main() { }