constant.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/integral_constant.hpp>
  5. #include <boost/hana/tuple.hpp>
  6. #include <boost/hana/value.hpp>
  7. #include <laws/constant.hpp>
  8. namespace hana = boost::hana;
  9. int main() {
  10. // value
  11. static_assert(hana::value(hana::integral_c<int, 0>) == 0, "");
  12. static_assert(hana::value(hana::integral_c<int, 1>) == 1, "");
  13. // laws
  14. hana::test::TestConstant<hana::integral_constant_tag<int>>{
  15. hana::make_tuple(
  16. hana::int_c<-10>,
  17. hana::int_c<-2>,
  18. hana::int_c<0>,
  19. hana::int_c<1>,
  20. hana::int_c<3>,
  21. hana::int_c<4>
  22. ),
  23. hana::tuple_t<int, long, long long>
  24. };
  25. hana::test::TestConstant<hana::integral_constant_tag<bool>>{
  26. hana::make_tuple(
  27. hana::true_c, hana::false_c
  28. ),
  29. hana::tuple_t<bool>
  30. };
  31. }