mcd.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031
  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 "minimal.hpp"
  5. #include <boost/hana/concept/constant.hpp>
  6. #include <boost/hana/value.hpp>
  7. namespace hana = boost::hana;
  8. // Make sure we really satisfy Constant.
  9. static_assert(hana::Constant<minimal_constant<int, 0>>::value, "");
  10. static_assert(hana::Constant<minimal_constant<int, 1>>::value, "");
  11. static_assert(hana::Constant<minimal_constant<int, 2>>::value, "");
  12. static_assert(hana::Constant<minimal_constant<int, 3>>::value, "");
  13. // Make sure we can use hana::value<> properly.
  14. static_assert(hana::value<minimal_constant<int, 0>>() == 0, "");
  15. static_assert(hana::value<minimal_constant<int, 1>>() == 1, "");
  16. static_assert(hana::value<minimal_constant<int, 2>>() == 2, "");
  17. static_assert(hana::value<minimal_constant<int, 3>>() == 3, "");
  18. // Check the equivalence between `value(...)` and `value<decltype(...)>()`.
  19. static_assert(hana::value(minimal_constant<int, 0>{}) == hana::value<minimal_constant<int, 0>>(), "");
  20. static_assert(hana::value(minimal_constant<int, 1>{}) == hana::value<minimal_constant<int, 1>>(), "");
  21. static_assert(hana::value(minimal_constant<int, 2>{}) == hana::value<minimal_constant<int, 2>>(), "");
  22. static_assert(hana::value(minimal_constant<int, 3>{}) == hana::value<minimal_constant<int, 3>>(), "");
  23. int main() { }