fold_left.cpp 707 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/fold_left.hpp>
  7. #include <boost/hana/optional.hpp>
  8. #include <laws/base.hpp>
  9. namespace hana = boost::hana;
  10. int main() {
  11. hana::test::ct_eq<2> x{};
  12. hana::test::ct_eq<3> s{};
  13. hana::test::_injection<0> f{};
  14. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  15. hana::fold_left(hana::just(x), s, f),
  16. f(s, x)
  17. ));
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. hana::fold_left(hana::nothing, s, f),
  20. s
  21. ));
  22. }