libstdcpp3.hpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. // (C) Copyright John Maddock 2001.
  2. // (C) Copyright Jens Maurer 2001.
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. // See http://www.boost.org for most recent version.
  7. // config for libstdc++ v3
  8. // not much to go in here:
  9. #define BOOST_GNU_STDLIB 1
  10. #ifdef __GLIBCXX__
  11. #define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCXX__)
  12. #else
  13. #define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCPP__)
  14. #endif
  15. #if !defined(_GLIBCPP_USE_WCHAR_T) && !defined(_GLIBCXX_USE_WCHAR_T)
  16. # define BOOST_NO_CWCHAR
  17. # define BOOST_NO_CWCTYPE
  18. # define BOOST_NO_STD_WSTRING
  19. # define BOOST_NO_STD_WSTREAMBUF
  20. #endif
  21. #if defined(__osf__) && !defined(_REENTRANT) \
  22. && ( defined(_GLIBCXX_HAVE_GTHR_DEFAULT) || defined(_GLIBCPP_HAVE_GTHR_DEFAULT) )
  23. // GCC 3 on Tru64 forces the definition of _REENTRANT when any std lib header
  24. // file is included, therefore for consistency we define it here as well.
  25. # define _REENTRANT
  26. #endif
  27. #ifdef __GLIBCXX__ // gcc 3.4 and greater:
  28. # if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
  29. || defined(_GLIBCXX__PTHREADS) \
  30. || defined(_GLIBCXX_HAS_GTHREADS) \
  31. || defined(_WIN32) \
  32. || defined(_AIX) \
  33. || defined(__HAIKU__)
  34. //
  35. // If the std lib has thread support turned on, then turn it on in Boost
  36. // as well. We do this because some gcc-3.4 std lib headers define _REENTANT
  37. // while others do not...
  38. //
  39. # define BOOST_HAS_THREADS
  40. # else
  41. # define BOOST_DISABLE_THREADS
  42. # endif
  43. #elif defined(__GLIBCPP__) \
  44. && !defined(_GLIBCPP_HAVE_GTHR_DEFAULT) \
  45. && !defined(_GLIBCPP__PTHREADS)
  46. // disable thread support if the std lib was built single threaded:
  47. # define BOOST_DISABLE_THREADS
  48. #endif
  49. #if (defined(linux) || defined(__linux) || defined(__linux__)) && defined(__arm__) && defined(_GLIBCPP_HAVE_GTHR_DEFAULT)
  50. // linux on arm apparently doesn't define _REENTRANT
  51. // so just turn on threading support whenever the std lib is thread safe:
  52. # define BOOST_HAS_THREADS
  53. #endif
  54. #if !defined(_GLIBCPP_USE_LONG_LONG) \
  55. && !defined(_GLIBCXX_USE_LONG_LONG)\
  56. && defined(BOOST_HAS_LONG_LONG)
  57. // May have been set by compiler/*.hpp, but "long long" without library
  58. // support is useless.
  59. # undef BOOST_HAS_LONG_LONG
  60. #endif
  61. // Apple doesn't seem to reliably defined a *unix* macro
  62. #if !defined(CYGWIN) && ( defined(__unix__) \
  63. || defined(__unix) \
  64. || defined(unix) \
  65. || defined(__APPLE__) \
  66. || defined(__APPLE) \
  67. || defined(APPLE))
  68. # include <unistd.h>
  69. #endif
  70. #ifndef __VXWORKS__ // VxWorks uses Dinkum, not GNU STL with GCC
  71. #if defined(__GLIBCXX__) || (defined(__GLIBCPP__) && __GLIBCPP__>=20020514) // GCC >= 3.1.0
  72. # define BOOST_STD_EXTENSION_NAMESPACE __gnu_cxx
  73. # define BOOST_HAS_SLIST
  74. # define BOOST_HAS_HASH
  75. # define BOOST_SLIST_HEADER <ext/slist>
  76. # if !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
  77. # define BOOST_HASH_SET_HEADER <ext/hash_set>
  78. # define BOOST_HASH_MAP_HEADER <ext/hash_map>
  79. # else
  80. # define BOOST_HASH_SET_HEADER <backward/hash_set>
  81. # define BOOST_HASH_MAP_HEADER <backward/hash_map>
  82. # endif
  83. #endif
  84. #endif
  85. #if defined(__has_include)
  86. #if defined(BOOST_HAS_HASH)
  87. #if !__has_include(BOOST_HASH_SET_HEADER) || (__GNUC__ >= 10)
  88. #undef BOOST_HAS_HASH
  89. #undef BOOST_HAS_SET_HEADER
  90. #undef BOOST_HAS_MAP_HEADER
  91. #endif
  92. #if !__has_include(BOOST_SLIST_HEADER)
  93. #undef BOOST_HAS_SLIST
  94. #undef BOOST_HAS_SLIST_HEADER
  95. #endif
  96. #endif
  97. #endif
  98. //
  99. // Decide whether we have C++11 support turned on:
  100. //
  101. #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103)
  102. # define BOOST_LIBSTDCXX11
  103. #endif
  104. //
  105. // Decide which version of libstdc++ we have, normally
  106. // libstdc++ C++0x support is detected via __GNUC__, __GNUC_MINOR__, and possibly
  107. // __GNUC_PATCHLEVEL__ at the suggestion of Jonathan Wakely, one of the libstdc++
  108. // developers. He also commented:
  109. //
  110. // "I'm not sure how useful __GLIBCXX__ is for your purposes, for instance in
  111. // GCC 4.2.4 it is set to 20080519 but in GCC 4.3.0 it is set to 20080305.
  112. // Although 4.3.0 was released earlier than 4.2.4, it has better C++0x support
  113. // than any release in the 4.2 series."
  114. //
  115. // Another resource for understanding libstdc++ features is:
  116. // http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#manual.intro.status.standard.200x
  117. //
  118. // However, using the GCC version number fails when the compiler is clang since this
  119. // only ever claims to emulate GCC-4.2, see https://svn.boost.org/trac/boost/ticket/7473
  120. // for a long discussion on this issue. What we can do though is use clang's __has_include
  121. // to detect the presence of a C++11 header that was introduced with a specific GCC release.
  122. // We still have to be careful though as many such headers were buggy and/or incomplete when
  123. // first introduced, so we only check for headers that were fully featured from day 1, and then
  124. // use that to infer the underlying GCC version:
  125. //
  126. #ifdef __clang__
  127. #if __has_include(<compare>)
  128. # define BOOST_LIBSTDCXX_VERSION 100100
  129. #elif __has_include(<memory_resource>)
  130. # define BOOST_LIBSTDCXX_VERSION 90100
  131. #elif __has_include(<charconv>)
  132. # define BOOST_LIBSTDCXX_VERSION 80100
  133. #elif __has_include(<variant>)
  134. # define BOOST_LIBSTDCXX_VERSION 70100
  135. #elif __has_include(<experimental/memory_resource>)
  136. # define BOOST_LIBSTDCXX_VERSION 60100
  137. #elif __has_include(<experimental/any>)
  138. # define BOOST_LIBSTDCXX_VERSION 50100
  139. #elif __has_include(<shared_mutex>)
  140. # define BOOST_LIBSTDCXX_VERSION 40900
  141. #elif __has_include(<ext/cmath>)
  142. # define BOOST_LIBSTDCXX_VERSION 40800
  143. #elif __has_include(<scoped_allocator>)
  144. # define BOOST_LIBSTDCXX_VERSION 40700
  145. #elif __has_include(<typeindex>)
  146. # define BOOST_LIBSTDCXX_VERSION 40600
  147. #elif __has_include(<future>)
  148. # define BOOST_LIBSTDCXX_VERSION 40500
  149. #elif __has_include(<ratio>)
  150. # define BOOST_LIBSTDCXX_VERSION 40400
  151. #elif __has_include(<array>)
  152. # define BOOST_LIBSTDCXX_VERSION 40300
  153. #endif
  154. #if (BOOST_LIBSTDCXX_VERSION >= 100000) && defined(BOOST_HAS_HASH)
  155. //
  156. // hash_set/hash_map deprecated and have terminal bugs:
  157. //
  158. #undef BOOST_HAS_HASH
  159. #undef BOOST_HAS_SET_HEADER
  160. #undef BOOST_HAS_MAP_HEADER
  161. #endif
  162. #if (BOOST_LIBSTDCXX_VERSION < 50100)
  163. // libstdc++ does not define this function as it's deprecated in C++11, but clang still looks for it,
  164. // defining it here is a terrible cludge, but should get things working:
  165. extern "C" char *gets (char *__s);
  166. #endif
  167. //
  168. // clang is unable to parse some GCC headers, add those workarounds here:
  169. //
  170. #if BOOST_LIBSTDCXX_VERSION < 50000
  171. # define BOOST_NO_CXX11_HDR_REGEX
  172. #endif
  173. //
  174. // GCC 4.7.x has no __cxa_thread_atexit which
  175. // thread_local objects require for cleanup:
  176. //
  177. #if BOOST_LIBSTDCXX_VERSION < 40800
  178. # define BOOST_NO_CXX11_THREAD_LOCAL
  179. #endif
  180. //
  181. // Early clang versions can handle <chrono>, not exactly sure which versions
  182. // but certainly up to clang-3.8 and gcc-4.6:
  183. //
  184. #if (__clang_major__ < 5)
  185. # if BOOST_LIBSTDCXX_VERSION < 40800
  186. # define BOOST_NO_CXX11_HDR_FUTURE
  187. # define BOOST_NO_CXX11_HDR_MUTEX
  188. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  189. # define BOOST_NO_CXX11_HDR_CHRONO
  190. # endif
  191. #endif
  192. //
  193. // GCC 4.8 and 9 add working versions of <atomic> and <regex> respectively.
  194. // However, we have no test for these as the headers were present but broken
  195. // in early GCC versions.
  196. //
  197. #endif
  198. #if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) && (__cplusplus >= 201103L)
  199. //
  200. // Oracle Solaris compiler uses it's own verison of libstdc++ but doesn't
  201. // set __GNUC__
  202. //
  203. #if __SUNPRO_CC >= 0x5140
  204. #define BOOST_LIBSTDCXX_VERSION 50100
  205. #else
  206. #define BOOST_LIBSTDCXX_VERSION 40800
  207. #endif
  208. #endif
  209. #if !defined(BOOST_LIBSTDCXX_VERSION)
  210. # define BOOST_LIBSTDCXX_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  211. #endif
  212. // std::auto_ptr isn't provided with _GLIBCXX_DEPRECATED=0 (GCC 4.5 and earlier)
  213. // or _GLIBCXX_USE_DEPRECATED=0 (GCC 4.6 and later).
  214. #if defined(BOOST_LIBSTDCXX11)
  215. # if BOOST_LIBSTDCXX_VERSION < 40600
  216. # if !_GLIBCXX_DEPRECATED
  217. # define BOOST_NO_AUTO_PTR
  218. # endif
  219. # elif !_GLIBCXX_USE_DEPRECATED
  220. # define BOOST_NO_AUTO_PTR
  221. # define BOOST_NO_CXX98_BINDERS
  222. # endif
  223. #endif
  224. // C++0x headers in GCC 4.3.0 and later
  225. //
  226. #if (BOOST_LIBSTDCXX_VERSION < 40300) || !defined(BOOST_LIBSTDCXX11)
  227. # define BOOST_NO_CXX11_HDR_ARRAY
  228. # define BOOST_NO_CXX11_HDR_TUPLE
  229. # define BOOST_NO_CXX11_HDR_UNORDERED_MAP
  230. # define BOOST_NO_CXX11_HDR_UNORDERED_SET
  231. # define BOOST_NO_CXX11_HDR_FUNCTIONAL
  232. #endif
  233. // C++0x headers in GCC 4.4.0 and later
  234. //
  235. #if (BOOST_LIBSTDCXX_VERSION < 40400) || !defined(BOOST_LIBSTDCXX11)
  236. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  237. # define BOOST_NO_CXX11_HDR_FORWARD_LIST
  238. # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  239. # define BOOST_NO_CXX11_HDR_MUTEX
  240. # define BOOST_NO_CXX11_HDR_RATIO
  241. # define BOOST_NO_CXX11_HDR_SYSTEM_ERROR
  242. # define BOOST_NO_CXX11_SMART_PTR
  243. # define BOOST_NO_CXX11_HDR_EXCEPTION
  244. #else
  245. # define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
  246. # define BOOST_HAS_TR1_COMPLEX_OVERLOADS
  247. #endif
  248. // C++0x features in GCC 4.5.0 and later
  249. //
  250. #if (BOOST_LIBSTDCXX_VERSION < 40500) || !defined(BOOST_LIBSTDCXX11)
  251. # define BOOST_NO_CXX11_NUMERIC_LIMITS
  252. # define BOOST_NO_CXX11_HDR_FUTURE
  253. # define BOOST_NO_CXX11_HDR_RANDOM
  254. #endif
  255. // C++0x features in GCC 4.6.0 and later
  256. //
  257. #if (BOOST_LIBSTDCXX_VERSION < 40600) || !defined(BOOST_LIBSTDCXX11)
  258. # define BOOST_NO_CXX11_HDR_TYPEINDEX
  259. # define BOOST_NO_CXX11_ADDRESSOF
  260. # define BOOST_NO_CXX17_ITERATOR_TRAITS
  261. #endif
  262. // C++0x features in GCC 4.7.0 and later
  263. //
  264. #if (BOOST_LIBSTDCXX_VERSION < 40700) || !defined(BOOST_LIBSTDCXX11)
  265. // Note that although <chrono> existed prior to 4.7, "steady_clock" is spelled "monotonic_clock"
  266. // so 4.7.0 is the first truly conforming one.
  267. # define BOOST_NO_CXX11_HDR_CHRONO
  268. # define BOOST_NO_CXX11_ALLOCATOR
  269. # define BOOST_NO_CXX11_POINTER_TRAITS
  270. #endif
  271. // C++0x features in GCC 4.8.0 and later
  272. //
  273. #if (BOOST_LIBSTDCXX_VERSION < 40800) || !defined(BOOST_LIBSTDCXX11)
  274. // Note that although <atomic> existed prior to gcc 4.8 it was largely unimplemented for many types:
  275. # define BOOST_NO_CXX11_HDR_ATOMIC
  276. # define BOOST_NO_CXX11_HDR_THREAD
  277. #endif
  278. // C++0x features in GCC 4.9.0 and later
  279. //
  280. #if (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  281. // Although <regex> is present and compilable against, the actual implementation is not functional
  282. // even for the simplest patterns such as "\d" or "[0-9]". This is the case at least in gcc up to 4.8, inclusively.
  283. # define BOOST_NO_CXX11_HDR_REGEX
  284. #endif
  285. #if (BOOST_LIBSTDCXX_VERSION < 40900) || (__cplusplus <= 201103)
  286. # define BOOST_NO_CXX14_STD_EXCHANGE
  287. #endif
  288. #if defined(__clang_major__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 7)))
  289. // As of clang-3.6, libstdc++ header <atomic> throws up errors with clang:
  290. # define BOOST_NO_CXX11_HDR_ATOMIC
  291. #endif
  292. //
  293. // C++0x features in GCC 5.1 and later
  294. //
  295. #if (BOOST_LIBSTDCXX_VERSION < 50100) || !defined(BOOST_LIBSTDCXX11)
  296. # define BOOST_NO_CXX11_HDR_TYPE_TRAITS
  297. # define BOOST_NO_CXX11_HDR_CODECVT
  298. # define BOOST_NO_CXX11_ATOMIC_SMART_PTR
  299. # define BOOST_NO_CXX11_STD_ALIGN
  300. #endif
  301. //
  302. // C++17 features in GCC 7.1 and later
  303. //
  304. #if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
  305. # define BOOST_NO_CXX17_STD_INVOKE
  306. # define BOOST_NO_CXX17_STD_APPLY
  307. # define BOOST_NO_CXX17_HDR_OPTIONAL
  308. # define BOOST_NO_CXX17_HDR_STRING_VIEW
  309. # define BOOST_NO_CXX17_HDR_VARIANT
  310. #endif
  311. #if defined(__has_include)
  312. #if !__has_include(<shared_mutex>)
  313. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  314. #elif __cplusplus <= 201103
  315. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  316. #endif
  317. //
  318. // <execution> has a dependency to Intel's thread building blocks:
  319. // unless these are installed seperately, including <execution> leads
  320. // to inscrutable errors inside libstdc++'s own headers.
  321. //
  322. #if (BOOST_LIBSTDCXX_VERSION < 100100)
  323. #if !__has_include(<tbb/tbb.h>)
  324. #define BOOST_NO_CXX17_HDR_EXECUTION
  325. #endif
  326. #endif
  327. #elif __cplusplus < 201402 || (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11)
  328. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  329. #endif
  330. #if BOOST_LIBSTDCXX_VERSION < 100100
  331. //
  332. // The header may be present but is incomplete:
  333. //
  334. # define BOOST_NO_CXX17_HDR_CHARCONV
  335. #endif
  336. //
  337. // Headers not present on Solaris with the Oracle compiler:
  338. #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
  339. #define BOOST_NO_CXX11_HDR_FUTURE
  340. #define BOOST_NO_CXX11_HDR_FORWARD_LIST
  341. #define BOOST_NO_CXX11_HDR_ATOMIC
  342. // shared_ptr is present, but is not convertible to bool
  343. // which causes all kinds of problems especially in Boost.Thread
  344. // but probably elsewhere as well.
  345. #define BOOST_NO_CXX11_SMART_PTR
  346. #endif
  347. #if (!defined(_GLIBCXX_HAS_GTHREADS) || !defined(_GLIBCXX_USE_C99_STDINT_TR1))
  348. // Headers not always available:
  349. # ifndef BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  350. # define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
  351. # endif
  352. # ifndef BOOST_NO_CXX11_HDR_MUTEX
  353. # define BOOST_NO_CXX11_HDR_MUTEX
  354. # endif
  355. # ifndef BOOST_NO_CXX11_HDR_THREAD
  356. # define BOOST_NO_CXX11_HDR_THREAD
  357. # endif
  358. # ifndef BOOST_NO_CXX14_HDR_SHARED_MUTEX
  359. # define BOOST_NO_CXX14_HDR_SHARED_MUTEX
  360. # endif
  361. #endif
  362. #if (!defined(_GTHREAD_USE_MUTEX_TIMEDLOCK) || (_GTHREAD_USE_MUTEX_TIMEDLOCK == 0)) && !defined(BOOST_NO_CXX11_HDR_MUTEX)
  363. // Timed mutexes are not always available:
  364. # define BOOST_NO_CXX11_HDR_MUTEX
  365. #endif
  366. // --- end ---