chain.cpp 976 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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/chain.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/optional.hpp>
  8. #include <laws/base.hpp>
  9. namespace hana = boost::hana;
  10. using hana::test::ct_eq;
  11. int main() {
  12. auto f = [](auto x) {
  13. return hana::just(hana::test::_injection<0>{}(x));
  14. };
  15. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  16. hana::chain(hana::just(ct_eq<3>{}), f),
  17. f(ct_eq<3>{})
  18. ));
  19. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  20. hana::chain(hana::nothing, f),
  21. hana::nothing
  22. ));
  23. // test with operators
  24. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  25. hana::just(ct_eq<3>{}) | f,
  26. f(ct_eq<3>{})
  27. ));
  28. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  29. hana::nothing | f,
  30. hana::nothing
  31. ));
  32. }