typeof.hpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // Copyright (C) 2004 Arkadiy Vertleyb
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
  5. #define BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
  6. #if defined(BOOST_TYPEOF_COMPLIANT)
  7. # define BOOST_TYPEOF_EMULATION
  8. #endif
  9. #if defined(BOOST_TYPEOF_EMULATION) && defined(BOOST_TYPEOF_NATIVE)
  10. # error both typeof emulation and native mode requested
  11. #endif
  12. #include <boost/config.hpp>
  13. #include <boost/config/workaround.hpp>
  14. #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1900) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION)
  15. # define BOOST_TYPEOF_DECLTYPE
  16. # ifndef BOOST_TYPEOF_NATIVE
  17. # define BOOST_TYPEOF_NATIVE
  18. # endif
  19. #elif defined(__COMO__)
  20. # ifdef __GNUG__
  21. # ifndef BOOST_TYPEOF_EMULATION
  22. # ifndef BOOST_TYPEOF_NATIVE
  23. # define BOOST_TYPEOF_NATIVE
  24. # endif
  25. # define BOOST_TYPEOF_KEYWORD typeof
  26. # endif
  27. # else
  28. # ifndef BOOST_TYPEOF_NATIVE
  29. # ifndef BOOST_TYPEOF_EMULATION
  30. # define BOOST_TYPEOF_EMULATION
  31. # endif
  32. # else
  33. # error native typeof is not supported
  34. # endif
  35. # endif
  36. #elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
  37. # ifdef __GNUC__
  38. # ifndef BOOST_TYPEOF_EMULATION
  39. # ifndef BOOST_TYPEOF_NATIVE
  40. # define BOOST_TYPEOF_NATIVE
  41. # endif
  42. # define BOOST_TYPEOF_KEYWORD __typeof__
  43. # endif
  44. # else
  45. # ifndef BOOST_TYPEOF_NATIVE
  46. # ifndef BOOST_TYPEOF_EMULATION
  47. # define BOOST_TYPEOF_EMULATION
  48. # endif
  49. # else
  50. # error native typeof is not supported
  51. # endif
  52. # endif
  53. #elif defined(__GNUC__) || defined(__clang__)
  54. # ifndef BOOST_TYPEOF_EMULATION
  55. # ifndef BOOST_TYPEOF_NATIVE
  56. # define BOOST_TYPEOF_NATIVE
  57. # endif
  58. # define BOOST_TYPEOF_KEYWORD __typeof__
  59. # endif
  60. #elif defined(__MWERKS__)
  61. # if(__MWERKS__ <= 0x3003) // 8.x
  62. # ifndef BOOST_TYPEOF_EMULATION
  63. # ifndef BOOST_TYPEOF_NATIVE
  64. # define BOOST_TYPEOF_NATIVE
  65. # endif
  66. # define BOOST_TYPEOF_KEYWORD __typeof__
  67. # else
  68. # define BOOST_TYPEOF_EMULATION_UNSUPPORTED
  69. # endif
  70. # else // 9.x
  71. # ifndef BOOST_TYPEOF_EMULATION
  72. # ifndef BOOST_TYPEOF_NATIVE
  73. # define BOOST_TYPEOF_NATIVE
  74. # endif
  75. # define BOOST_TYPEOF_KEYWORD __typeof__
  76. # endif
  77. # endif
  78. #elif defined __CODEGEARC__
  79. # ifndef BOOST_TYPEOF_EMULATION
  80. # ifndef BOOST_TYPEOF_NATIVE
  81. # define BOOST_TYPEOF_EMULATION_UNSUPPORTED
  82. # endif
  83. # else
  84. # define BOOST_TYPEOF_EMULATION_UNSUPPORTED
  85. # endif
  86. #elif defined __BORLANDC__
  87. # ifndef BOOST_TYPEOF_EMULATION
  88. # ifndef BOOST_TYPEOF_NATIVE
  89. # define BOOST_TYPEOF_EMULATION_UNSUPPORTED
  90. # endif
  91. # else
  92. # define BOOST_TYPEOF_EMULATION_UNSUPPORTED
  93. # endif
  94. #elif defined __DMC__
  95. # ifndef BOOST_TYPEOF_EMULATION
  96. # ifndef BOOST_TYPEOF_NATIVE
  97. # define BOOST_TYPEOF_NATIVE
  98. # endif
  99. # include <boost/typeof/dmc/typeof_impl.hpp>
  100. # define MSVC_TYPEOF_HACK
  101. # endif
  102. #elif defined(_MSC_VER)
  103. # if (_MSC_VER >= 1310) // 7.1 ->
  104. # ifndef BOOST_TYPEOF_EMULATION
  105. # ifndef BOOST_TYPEOF_NATIVE
  106. # ifndef _MSC_EXTENSIONS
  107. # define BOOST_TYPEOF_EMULATION
  108. # else
  109. # define BOOST_TYPEOF_NATIVE
  110. # endif
  111. # endif
  112. # endif
  113. # ifdef BOOST_TYPEOF_NATIVE
  114. # include <boost/typeof/msvc/typeof_impl.hpp>
  115. # define MSVC_TYPEOF_HACK
  116. # endif
  117. # endif
  118. #elif defined(__HP_aCC)
  119. # ifndef BOOST_TYPEOF_NATIVE
  120. # ifndef BOOST_TYPEOF_EMULATION
  121. # define BOOST_TYPEOF_EMULATION
  122. # endif
  123. # else
  124. # error native typeof is not supported
  125. # endif
  126. #elif defined(__DECCXX)
  127. # ifndef BOOST_TYPEOF_NATIVE
  128. # ifndef BOOST_TYPEOF_EMULATION
  129. # define BOOST_TYPEOF_EMULATION
  130. # endif
  131. # else
  132. # error native typeof is not supported
  133. # endif
  134. #elif defined(__BORLANDC__)
  135. # if (__BORLANDC__ < 0x590)
  136. # define BOOST_TYPEOF_NO_FUNCTION_TYPES
  137. # define BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
  138. # endif
  139. # ifndef BOOST_TYPEOF_NATIVE
  140. # ifndef BOOST_TYPEOF_EMULATION
  141. # define BOOST_TYPEOF_EMULATION
  142. # endif
  143. # else
  144. # error native typeof is not supported
  145. # endif
  146. #elif defined(__SUNPRO_CC)
  147. # if (__SUNPRO_CC < 0x590 )
  148. # ifdef BOOST_TYPEOF_NATIVE
  149. # error native typeof is not supported
  150. # endif
  151. # ifndef BOOST_TYPEOF_EMULATION
  152. # define BOOST_TYPEOF_EMULATION
  153. # endif
  154. # else
  155. # ifndef BOOST_TYPEOF_EMULATION
  156. # ifndef BOOST_TYPEOF_NATIVE
  157. # define BOOST_TYPEOF_NATIVE
  158. # endif
  159. # define BOOST_TYPEOF_KEYWORD __typeof__
  160. # endif
  161. # endif
  162. #elif defined(__IBM__TYPEOF__)
  163. # ifndef BOOST_TYPEOF_EMULATION
  164. # ifndef BOOST_TYPEOF_NATIVE
  165. # define BOOST_TYPEOF_NATIVE
  166. # endif
  167. # define BOOST_TYPEOF_KEYWORD __typeof__
  168. # endif
  169. #else //unknown compiler
  170. # ifndef BOOST_TYPEOF_NATIVE
  171. # ifndef BOOST_TYPEOF_EMULATION
  172. # define BOOST_TYPEOF_EMULATION
  173. # endif
  174. # else
  175. # ifndef BOOST_TYPEOF_KEYWORD
  176. # define BOOST_TYPEOF_KEYWORD typeof
  177. # endif
  178. # endif
  179. #endif
  180. #define BOOST_TYPEOF_UNIQUE_ID()\
  181. BOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__
  182. #define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\
  183. <boost/typeof/incr_registration_group.hpp>
  184. #ifdef BOOST_TYPEOF_EMULATION_UNSUPPORTED
  185. # include <boost/typeof/unsupported.hpp>
  186. #elif defined BOOST_TYPEOF_EMULATION
  187. # define BOOST_TYPEOF_TEXT "using typeof emulation"
  188. # include <boost/typeof/message.hpp>
  189. # include <boost/typeof/typeof_impl.hpp>
  190. # include <boost/typeof/type_encoding.hpp>
  191. # include <boost/typeof/template_encoding.hpp>
  192. # include <boost/typeof/modifiers.hpp>
  193. # include <boost/typeof/pointers_data_members.hpp>
  194. # include <boost/typeof/register_functions.hpp>
  195. # include <boost/typeof/register_fundamental.hpp>
  196. #elif defined(BOOST_TYPEOF_NATIVE)
  197. # define BOOST_TYPEOF_TEXT "using native typeof"
  198. # include <boost/typeof/message.hpp>
  199. # ifdef BOOST_TYPEOF_DECLTYPE
  200. # include <boost/typeof/decltype.hpp>
  201. # else
  202. # include <boost/typeof/native.hpp>
  203. # endif
  204. #else
  205. # error typeof configuration error
  206. #endif
  207. // auto
  208. #define BOOST_AUTO(Var, Expr) BOOST_TYPEOF(Expr) Var = Expr
  209. #define BOOST_AUTO_TPL(Var, Expr) BOOST_TYPEOF_TPL(Expr) Var = Expr
  210. #endif//BOOST_TYPEOF_TYPEOF_HPP_INCLUDED