is_pod_test.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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_pod.hpp>
  9. #endif
  10. #include "test.hpp"
  11. #include "check_integral_constant.hpp"
  12. TT_TEST_BEGIN(is_pod)
  13. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<bool>::value, true);
  14. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<bool const>::value, true);
  15. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<bool volatile>::value, true);
  16. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<bool const volatile>::value, true);
  17. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<signed char>::value, true);
  18. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<signed char const>::value, true);
  19. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<signed char volatile>::value, true);
  20. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<signed char const volatile>::value, true);
  21. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned char>::value, true);
  22. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char>::value, true);
  23. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned char const>::value, true);
  24. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char const>::value, true);
  25. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned char volatile>::value, true);
  26. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char volatile>::value, true);
  27. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned char const volatile>::value, true);
  28. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char const volatile>::value, true);
  29. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned short>::value, true);
  30. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<short>::value, true);
  31. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned short const>::value, true);
  32. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<short const>::value, true);
  33. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned short volatile>::value, true);
  34. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<short volatile>::value, true);
  35. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned short const volatile>::value, true);
  36. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<short const volatile>::value, true);
  37. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned int>::value, true);
  38. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int>::value, true);
  39. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned int const>::value, true);
  40. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int const>::value, true);
  41. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned int volatile>::value, true);
  42. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int volatile>::value, true);
  43. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned int const volatile>::value, true);
  44. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int const volatile>::value, true);
  45. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned long>::value, true);
  46. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long>::value, true);
  47. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned long const>::value, true);
  48. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long const>::value, true);
  49. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned long volatile>::value, true);
  50. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long volatile>::value, true);
  51. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned long const volatile>::value, true);
  52. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long const volatile>::value, true);
  53. #ifdef BOOST_HAS_LONG_LONG
  54. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::ulong_long_type>::value, true);
  55. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::long_long_type>::value, true);
  56. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::ulong_long_type const>::value, true);
  57. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::long_long_type const>::value, true);
  58. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::ulong_long_type volatile>::value, true);
  59. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::long_long_type volatile>::value, true);
  60. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::ulong_long_type const volatile>::value, true);
  61. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod< ::boost::long_long_type const volatile>::value, true);
  62. #endif
  63. #ifdef BOOST_HAS_MS_INT64
  64. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int8>::value, true);
  65. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int8>::value, true);
  66. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int8 const>::value, true);
  67. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int8 const>::value, true);
  68. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int8 volatile>::value, true);
  69. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int8 volatile>::value, true);
  70. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int8 const volatile>::value, true);
  71. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int8 const volatile>::value, true);
  72. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int16>::value, true);
  73. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int16>::value, true);
  74. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int16 const>::value, true);
  75. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int16 const>::value, true);
  76. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int16 volatile>::value, true);
  77. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int16 volatile>::value, true);
  78. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int16 const volatile>::value, true);
  79. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int16 const volatile>::value, true);
  80. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int32>::value, true);
  81. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int32>::value, true);
  82. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int32 const>::value, true);
  83. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int32 const>::value, true);
  84. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int32 volatile>::value, true);
  85. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int32 volatile>::value, true);
  86. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int32 const volatile>::value, true);
  87. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int32 const volatile>::value, true);
  88. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int64>::value, true);
  89. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int64>::value, true);
  90. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int64 const>::value, true);
  91. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int64 const>::value, true);
  92. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int64 volatile>::value, true);
  93. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int64 volatile>::value, true);
  94. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<unsigned __int64 const volatile>::value, true);
  95. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<__int64 const volatile>::value, true);
  96. #endif
  97. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<float>::value, true);
  98. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<float const>::value, true);
  99. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<float volatile>::value, true);
  100. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<float const volatile>::value, true);
  101. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<double>::value, true);
  102. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<double const>::value, true);
  103. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<double volatile>::value, true);
  104. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<double const volatile>::value, true);
  105. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long double>::value, true);
  106. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long double const>::value, true);
  107. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long double volatile>::value, true);
  108. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<long double const volatile>::value, true);
  109. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int>::value, true);
  110. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<void*>::value, true);
  111. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int*const>::value, true);
  112. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<f1>::value, true);
  113. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<f2>::value, true);
  114. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<f3>::value, true);
  115. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<mf1>::value, true);
  116. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<mf2>::value, true);
  117. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<mf3>::value, true);
  118. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<mp>::value, true);
  119. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<cmf>::value, true);
  120. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<enum_UDT>::value, true);
  121. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int&>::value, false);
  122. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  123. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int&&>::value, false);
  124. #endif
  125. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<const int&>::value, false);
  126. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int[2]>::value, true);
  127. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int[3][2]>::value, true);
  128. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<int[2][4][5][6][3]>::value, true);
  129. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<UDT>::value, false);
  130. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<empty_UDT>::value, false);
  131. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<void>::value, true);
  132. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<test_abc1>::value, false);
  133. // cases we would like to succeed but can't implement in the language:
  134. BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_pod<empty_POD_UDT>::value, true, false);
  135. BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_pod<POD_UDT>::value, true, false);
  136. BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_pod<POD_union_UDT>::value, true, false);
  137. BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_pod<empty_POD_union_UDT>::value, true, false);
  138. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<trivial_except_copy>::value, false);
  139. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<trivial_except_destroy>::value, false);
  140. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<trivial_except_assign>::value, false);
  141. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<trivial_except_construct>::value, false);
  142. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<wrap<trivial_except_copy> >::value, false);
  143. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<wrap<trivial_except_assign> >::value, false);
  144. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<wrap<trivial_except_destroy> >::value, false);
  145. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<wrap<trivial_except_construct> >::value, false);
  146. #ifndef BOOST_NO_CXX11_CHAR16_T
  147. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char16_t>::value, true);
  148. #endif
  149. #ifndef BOOST_NO_CXX11_CHAR32_T
  150. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<char32_t>::value, true);
  151. #endif
  152. #ifdef BOOST_HAS_INT128
  153. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<boost::int128_type>::value, true);
  154. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<boost::uint128_type>::value, true);
  155. #endif
  156. #ifdef BOOST_HAS_FLOAT128
  157. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<boost::float128_type>::value, true);
  158. #endif
  159. TT_TEST_END