unpack.cpp 875 B

12345678910111213141516171819202122232425262728293031323334
  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 <boost/hana/unpack.hpp>
  8. #include <laws/base.hpp>
  9. namespace hana = boost::hana;
  10. int main() {
  11. hana::test::ct_eq<2> x{};
  12. hana::test::_injection<0> f{};
  13. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  14. hana::unpack(hana::nothing, f),
  15. f()
  16. ));
  17. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  18. hana::unpack(hana::just(x), f),
  19. f(x)
  20. ));
  21. // Previously, there was a bug that would make this fail.
  22. auto non_const_nothing = hana::nothing;
  23. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  24. hana::unpack(non_const_nothing, f),
  25. f()
  26. ));
  27. }