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