is_detected_convertible.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright 2017-2018 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License,
  5. Version 1.0. (See accompanying file LICENSE_1_0.txt
  6. or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #include <boost/config.hpp>
  9. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
  10. !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  11. #ifdef TEST_STD
  12. #include <type_traits>
  13. #else
  14. #include <boost/type_traits/is_detected_convertible.hpp>
  15. #endif
  16. #include "check_integral_constant.hpp"
  17. #include "check_type.hpp"
  18. #define CHECK_FALSE(e) BOOST_CHECK_INTEGRAL_CONSTANT(e, false)
  19. #define CHECK_TRUE(e) BOOST_CHECK_INTEGRAL_CONSTANT(e, true)
  20. template<class T>
  21. using type_t = typename T::type;
  22. struct has_type {
  23. using type = char;
  24. };
  25. struct no_type { };
  26. TT_TEST_BEGIN(is_detected_convertible)
  27. CHECK_FALSE((::tt::is_detected_convertible<long, type_t, int>::value));
  28. CHECK_TRUE((::tt::is_detected_convertible<long, type_t, has_type>::value));
  29. CHECK_FALSE((::tt::is_detected_convertible<long, type_t, no_type>::value));
  30. #ifndef BOOST_NO_CXX14_VARIABLE_TEMPLATES
  31. CHECK_FALSE((::tt::is_detected_convertible_v<long, type_t, int>));
  32. CHECK_TRUE((::tt::is_detected_convertible_v<long, type_t, has_type>));
  33. CHECK_FALSE((::tt::is_detected_convertible_v<long, type_t, no_type>));
  34. #endif
  35. TT_TEST_END
  36. #else
  37. int main()
  38. {
  39. return 0;
  40. }
  41. #endif