std_api.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 <cstddef>
  6. #include <type_traits>
  7. namespace hana = boost::hana;
  8. // operator()
  9. static_assert(hana::size_c<0>() == 0, "");
  10. static_assert(hana::size_c<1>() == 1, "");
  11. static_assert(hana::int_c<-3>() == -3, "");
  12. // decltype(operator())
  13. static_assert(std::is_same<decltype(hana::size_c<0>()), std::size_t>{}, "");
  14. static_assert(std::is_same<decltype(hana::int_c<-3>()), int>{}, "");
  15. // conversions
  16. constexpr std::size_t a = hana::size_c<0>, b = hana::size_c<1>;
  17. static_assert(a == 0 && b == 1, "");
  18. constexpr int c = hana::int_c<0>, d = hana::int_c<-3>;
  19. static_assert(c == 0 && d == -3, "");
  20. // nested ::value
  21. static_assert(decltype(hana::int_c<1>)::value == 1, "");
  22. // nested ::type
  23. static_assert(std::is_same<
  24. decltype(hana::int_c<1>)::type,
  25. std::remove_cv_t<decltype(hana::int_c<1>)>
  26. >{}, "");
  27. // nested ::value_type
  28. static_assert(std::is_same<decltype(hana::int_c<1>)::value_type, int>{}, "");
  29. // inherits from std::integral_constant
  30. static_assert(std::is_base_of<std::integral_constant<int, 3>,
  31. hana::integral_constant<int, 3>>{}, "");
  32. int main() { }