is_pointer_test.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // (C) Copyright John Maddock 2000.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifdef TEST_STD
  6. # include <type_traits>
  7. #else
  8. # include <boost/type_traits/is_pointer.hpp>
  9. #endif
  10. #include "test.hpp"
  11. #include "check_integral_constant.hpp"
  12. TT_TEST_BEGIN(is_pointer)
  13. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int>::value, false);
  14. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int&>::value, false);
  15. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  16. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int&&>::value, false);
  17. #endif
  18. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int*>::value, true);
  19. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<const int*>::value, true);
  20. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<volatile int*>::value, true);
  21. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<non_pointer*>::value, true);
  22. // these were false in previous versions (JM 20 Dec 2000):
  23. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int*const>::value, true);
  24. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int*volatile>::value, true);
  25. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int*const volatile>::value, true);
  26. // JM 02 Oct 2000:
  27. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<non_pointer>::value, false);
  28. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int*&>::value, false);
  29. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int(&)[2]>::value, false);
  30. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int[2]>::value, false);
  31. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<char[sizeof(void*)]>::value, false);
  32. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<void>::value, false);
  33. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<f1>::value, true);
  34. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<f2>::value, true);
  35. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<f3>::value, true);
  36. // Steve: was 'true', should be 'false', via 3.9.2p3
  37. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<mf1>::value, false);
  38. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<mf2>::value, false);
  39. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<mf3>::value, false);
  40. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<mf4>::value, false);
  41. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<test_abc1>::value, false);
  42. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<foo0_t>::value, false);
  43. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<foo1_t>::value, false);
  44. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<foo2_t>::value, false);
  45. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<foo3_t>::value, false);
  46. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<foo4_t>::value, false);
  47. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<int(*const)()>::value, true);
  48. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<test_abc1>::value, false);
  49. TT_TEST_END