logical.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/eval_if.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/not.hpp>
  9. #include <boost/hana/tuple.hpp>
  10. #include <laws/base.hpp>
  11. #include <laws/logical.hpp>
  12. namespace hana = boost::hana;
  13. int main() {
  14. // eval_if
  15. {
  16. auto t = [](auto) { return hana::test::ct_eq<3>{}; };
  17. auto e = [](auto) { return hana::test::ct_eq<4>{}; };
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. hana::eval_if(hana::true_c, t, e),
  20. hana::test::ct_eq<3>{}
  21. ));
  22. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  23. hana::eval_if(hana::false_c, t, e),
  24. hana::test::ct_eq<4>{}
  25. ));
  26. }
  27. // not_
  28. {
  29. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  30. hana::not_(hana::true_c),
  31. hana::false_c
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  34. hana::not_(hana::false_c),
  35. hana::true_c
  36. ));
  37. }
  38. // laws
  39. hana::test::TestLogical<hana::integral_constant_tag<int>>{hana::make_tuple(
  40. hana::int_c<-2>, hana::int_c<0>, hana::int_c<1>, hana::int_c<3>
  41. )};
  42. hana::test::TestLogical<hana::integral_constant_tag<bool>>{hana::make_tuple(
  43. hana::false_c, hana::true_c
  44. )};
  45. }