nested_type.cpp 784 B

123456789101112131415161718192021222324252627282930313233
  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/optional.hpp>
  5. #include <boost/hana/type.hpp>
  6. #include <type_traits>
  7. namespace hana = boost::hana;
  8. // This test makes sure that an optional holding a hana::type has a
  9. // nested ::type alias.
  10. template <typename ...>
  11. using void_t = void;
  12. template <typename T, typename = void>
  13. struct has_type : std::false_type { };
  14. template <typename T>
  15. struct has_type<T, void_t<typename T::type>>
  16. : std::true_type
  17. { };
  18. struct T;
  19. static_assert(std::is_same<decltype(hana::just(hana::type_c<T>))::type, T>{}, "");
  20. static_assert(!has_type<decltype(hana::nothing)>{}, "");
  21. int main() { }