config.hpp 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422
  1. //
  2. // detail/config.hpp
  3. // ~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_DETAIL_CONFIG_HPP
  11. #define ASIO_DETAIL_CONFIG_HPP
  12. // boostify: non-boost code starts here
  13. #if !defined(ASIO_STANDALONE)
  14. # if !defined(ASIO_ENABLE_BOOST)
  15. # if (__cplusplus >= 201103)
  16. # define ASIO_STANDALONE 1
  17. # elif defined(_MSC_VER) && defined(_MSVC_LANG)
  18. # if (_MSC_VER >= 1900) && (_MSVC_LANG >= 201103)
  19. # define ASIO_STANDALONE 1
  20. # endif // (_MSC_VER >= 1900) && (_MSVC_LANG >= 201103)
  21. # endif // defined(_MSC_VER) && defined(_MSVC_LANG)
  22. # endif // !defined(ASIO_ENABLE_BOOST)
  23. #endif // !defined(ASIO_STANDALONE)
  24. // Make standard library feature macros available.
  25. #if defined(__has_include)
  26. # if __has_include(<version>)
  27. # include <version>
  28. # else // __has_include(<version>)
  29. # include <cstddef>
  30. # endif // __has_include(<version>)
  31. #else // defined(__has_include)
  32. # include <cstddef>
  33. #endif // defined(__has_include)
  34. // boostify: non-boost code ends here
  35. #if defined(ASIO_STANDALONE)
  36. # define ASIO_DISABLE_BOOST_ALIGN 1
  37. # define ASIO_DISABLE_BOOST_ARRAY 1
  38. # define ASIO_DISABLE_BOOST_ASSERT 1
  39. # define ASIO_DISABLE_BOOST_BIND 1
  40. # define ASIO_DISABLE_BOOST_CHRONO 1
  41. # define ASIO_DISABLE_BOOST_DATE_TIME 1
  42. # define ASIO_DISABLE_BOOST_LIMITS 1
  43. # define ASIO_DISABLE_BOOST_REGEX 1
  44. # define ASIO_DISABLE_BOOST_STATIC_CONSTANT 1
  45. # define ASIO_DISABLE_BOOST_THROW_EXCEPTION 1
  46. # define ASIO_DISABLE_BOOST_WORKAROUND 1
  47. #else // defined(ASIO_STANDALONE)
  48. // Boost.Config library is available.
  49. # include <boost/config.hpp>
  50. # include <boost/version.hpp>
  51. # define ASIO_HAS_BOOST_CONFIG 1
  52. #endif // defined(ASIO_STANDALONE)
  53. // Default to a header-only implementation. The user must specifically request
  54. // separate compilation by defining either ASIO_SEPARATE_COMPILATION or
  55. // ASIO_DYN_LINK (as a DLL/shared library implies separate compilation).
  56. #if !defined(ASIO_HEADER_ONLY)
  57. # if !defined(ASIO_SEPARATE_COMPILATION)
  58. # if !defined(ASIO_DYN_LINK)
  59. # define ASIO_HEADER_ONLY 1
  60. # endif // !defined(ASIO_DYN_LINK)
  61. # endif // !defined(ASIO_SEPARATE_COMPILATION)
  62. #endif // !defined(ASIO_HEADER_ONLY)
  63. #if defined(ASIO_HEADER_ONLY)
  64. # define ASIO_DECL inline
  65. #else // defined(ASIO_HEADER_ONLY)
  66. # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
  67. // We need to import/export our code only if the user has specifically asked
  68. // for it by defining ASIO_DYN_LINK.
  69. # if defined(ASIO_DYN_LINK)
  70. // Export if this is our own source, otherwise import.
  71. # if defined(ASIO_SOURCE)
  72. # define ASIO_DECL __declspec(dllexport)
  73. # else // defined(ASIO_SOURCE)
  74. # define ASIO_DECL __declspec(dllimport)
  75. # endif // defined(ASIO_SOURCE)
  76. # endif // defined(ASIO_DYN_LINK)
  77. # endif // defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
  78. #endif // defined(ASIO_HEADER_ONLY)
  79. // If ASIO_DECL isn't defined yet define it now.
  80. #if !defined(ASIO_DECL)
  81. # define ASIO_DECL
  82. #endif // !defined(ASIO_DECL)
  83. // Helper macro for documentation.
  84. #define ASIO_UNSPECIFIED(e) e
  85. // Microsoft Visual C++ detection.
  86. #if !defined(ASIO_MSVC)
  87. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_MSVC)
  88. # define ASIO_MSVC BOOST_MSVC
  89. # elif defined(_MSC_VER) && (defined(__INTELLISENSE__) \
  90. || (!defined(__MWERKS__) && !defined(__EDG_VERSION__)))
  91. # define ASIO_MSVC _MSC_VER
  92. # endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_MSVC)
  93. #endif // !defined(ASIO_MSVC)
  94. // Clang / libc++ detection.
  95. #if defined(__clang__)
  96. # if (__cplusplus >= 201103)
  97. # if __has_include(<__config>)
  98. # include <__config>
  99. # if defined(_LIBCPP_VERSION)
  100. # define ASIO_HAS_CLANG_LIBCXX 1
  101. # endif // defined(_LIBCPP_VERSION)
  102. # endif // __has_include(<__config>)
  103. # endif // (__cplusplus >= 201103)
  104. #endif // defined(__clang__)
  105. // Android platform detection.
  106. #if defined(__ANDROID__)
  107. # include <android/api-level.h>
  108. #endif // defined(__ANDROID__)
  109. // Always enabled. Retained for backwards compatibility in user code.
  110. #if !defined(ASIO_DISABLE_CXX11_MACROS)
  111. # define ASIO_HAS_MOVE 1
  112. # define ASIO_MOVE_ARG(type) type&&
  113. # define ASIO_MOVE_ARG2(type1, type2) type1, type2&&
  114. # define ASIO_NONDEDUCED_MOVE_ARG(type) type&
  115. # define ASIO_MOVE_CAST(type) static_cast<type&&>
  116. # define ASIO_MOVE_CAST2(type1, type2) static_cast<type1, type2&&>
  117. # define ASIO_MOVE_OR_LVALUE(type) static_cast<type&&>
  118. # define ASIO_MOVE_OR_LVALUE_ARG(type) type&&
  119. # define ASIO_MOVE_OR_LVALUE_TYPE(type) type
  120. # define ASIO_DELETED = delete
  121. # define ASIO_HAS_VARIADIC_TEMPLATES 1
  122. # define ASIO_HAS_CONSTEXPR 1
  123. # define ASIO_STATIC_CONSTEXPR(type, assignment) \
  124. static constexpr type assignment
  125. # define ASIO_HAS_NOEXCEPT 1
  126. # define ASIO_NOEXCEPT noexcept(true)
  127. # define ASIO_NOEXCEPT_OR_NOTHROW noexcept(true)
  128. # define ASIO_NOEXCEPT_IF(c) noexcept(c)
  129. # define ASIO_HAS_DECLTYPE 1
  130. # define ASIO_AUTO_RETURN_TYPE_PREFIX(t) auto
  131. # define ASIO_AUTO_RETURN_TYPE_PREFIX2(t0, t1) auto
  132. # define ASIO_AUTO_RETURN_TYPE_PREFIX3(t0, t1, t2) auto
  133. # define ASIO_AUTO_RETURN_TYPE_SUFFIX(expr) -> decltype expr
  134. # define ASIO_HAS_ALIAS_TEMPLATES 1
  135. # define ASIO_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS 1
  136. # define ASIO_HAS_ENUM_CLASS 1
  137. # define ASIO_HAS_REF_QUALIFIED_FUNCTIONS 1
  138. # define ASIO_LVALUE_REF_QUAL &
  139. # define ASIO_RVALUE_REF_QUAL &&
  140. # define ASIO_HAS_USER_DEFINED_LITERALS 1
  141. # define ASIO_HAS_ALIGNOF 1
  142. # define ASIO_ALIGNOF(T) alignof(T)
  143. # define ASIO_HAS_STD_ALIGN 1
  144. # define ASIO_HAS_STD_SYSTEM_ERROR 1
  145. # define ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true)
  146. # define ASIO_HAS_STD_ARRAY 1
  147. # define ASIO_HAS_STD_SHARED_PTR 1
  148. # define ASIO_HAS_STD_ALLOCATOR_ARG 1
  149. # define ASIO_HAS_STD_ATOMIC 1
  150. # define ASIO_HAS_STD_CHRONO 1
  151. # define ASIO_HAS_STD_ADDRESSOF 1
  152. # define ASIO_HAS_STD_FUNCTION 1
  153. # define ASIO_HAS_STD_REFERENCE_WRAPPER 1
  154. # define ASIO_HAS_STD_TYPE_TRAITS 1
  155. # define ASIO_HAS_NULLPTR 1
  156. # define ASIO_HAS_CXX11_ALLOCATORS 1
  157. # define ASIO_HAS_CSTDINT 1
  158. # define ASIO_HAS_STD_THREAD 1
  159. # define ASIO_HAS_STD_MUTEX_AND_CONDVAR 1
  160. # define ASIO_HAS_STD_CALL_ONCE 1
  161. # define ASIO_HAS_STD_FUTURE 1
  162. # define ASIO_HAS_STD_TUPLE 1
  163. # define ASIO_HAS_STD_IOSTREAM_MOVE 1
  164. # define ASIO_HAS_STD_EXCEPTION_PTR 1
  165. # define ASIO_HAS_STD_NESTED_EXCEPTION 1
  166. # define ASIO_HAS_STD_HASH 1
  167. #endif // !defined(ASIO_DISABLE_CXX11_MACROS)
  168. // Support for static constexpr with default initialisation.
  169. #if !defined(ASIO_STATIC_CONSTEXPR_DEFAULT_INIT)
  170. # if defined(__GNUC__)
  171. # if (__GNUC__ >= 8)
  172. # define ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(type, name) \
  173. static constexpr const type name{}
  174. # else // (__GNUC__ >= 8)
  175. # define ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(type, name) \
  176. static const type name
  177. # endif // (__GNUC__ >= 8)
  178. # elif defined(ASIO_MSVC)
  179. # define ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(type, name) \
  180. static const type name
  181. # else // defined(ASIO_MSVC)
  182. # define ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(type, name) \
  183. static constexpr const type name{}
  184. # endif // defined(ASIO_MSVC)
  185. #endif // !defined(ASIO_STATIC_CONSTEXPR_DEFAULT_INIT)
  186. // Support noexcept on function types on compilers known to allow it.
  187. #if !defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
  188. # if !defined(ASIO_DISABLE_NOEXCEPT_FUNCTION_TYPE)
  189. # if defined(__clang__)
  190. # if (__cplusplus >= 202002)
  191. # define ASIO_HAS_NOEXCEPT_FUNCTION_TYPE 1
  192. # endif // (__cplusplus >= 202002)
  193. # elif defined(__GNUC__)
  194. # if (__cplusplus >= 202002)
  195. # define ASIO_HAS_NOEXCEPT_FUNCTION_TYPE 1
  196. # endif // (__cplusplus >= 202002)
  197. # elif defined(ASIO_MSVC)
  198. # if (_MSC_VER >= 1900 && _MSVC_LANG >= 202002)
  199. # define ASIO_HAS_NOEXCEPT_FUNCTION_TYPE 1
  200. # endif // (_MSC_VER >= 1900 && _MSVC_LANG >= 202002)
  201. # endif // defined(ASIO_MSVC)
  202. # endif // !defined(ASIO_DISABLE_NOEXCEPT_FUNCTION_TYPE)
  203. #endif // !defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
  204. // Support return type deduction on compilers known to allow it.
  205. #if !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION)
  206. # if !defined(ASIO_DISABLE_RETURN_TYPE_DEDUCTION)
  207. # if defined(__clang__)
  208. # if __has_feature(__cxx_return_type_deduction__)
  209. # define ASIO_HAS_RETURN_TYPE_DEDUCTION 1
  210. # endif // __has_feature(__cxx_return_type_deduction__)
  211. # elif (__cplusplus >= 201402)
  212. # define ASIO_HAS_RETURN_TYPE_DEDUCTION 1
  213. # elif defined(__cpp_return_type_deduction)
  214. # if (__cpp_return_type_deduction >= 201304)
  215. # define ASIO_HAS_RETURN_TYPE_DEDUCTION 1
  216. # endif // (__cpp_return_type_deduction >= 201304)
  217. # elif defined(ASIO_MSVC)
  218. # if (_MSC_VER >= 1900 && _MSVC_LANG >= 201402)
  219. # define ASIO_HAS_RETURN_TYPE_DEDUCTION 1
  220. # endif // (_MSC_VER >= 1900 && _MSVC_LANG >= 201402)
  221. # endif // defined(ASIO_MSVC)
  222. # endif // !defined(ASIO_DISABLE_RETURN_TYPE_DEDUCTION)
  223. #endif // !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION)
  224. // Support concepts on compilers known to allow them.
  225. #if !defined(ASIO_HAS_CONCEPTS)
  226. # if !defined(ASIO_DISABLE_CONCEPTS)
  227. # if defined(__cpp_concepts)
  228. # define ASIO_HAS_CONCEPTS 1
  229. # if (__cpp_concepts >= 201707)
  230. # define ASIO_CONCEPT concept
  231. # else // (__cpp_concepts >= 201707)
  232. # define ASIO_CONCEPT concept bool
  233. # endif // (__cpp_concepts >= 201707)
  234. # endif // defined(__cpp_concepts)
  235. # endif // !defined(ASIO_DISABLE_CONCEPTS)
  236. #endif // !defined(ASIO_HAS_CONCEPTS)
  237. // Support concepts on compilers known to allow them.
  238. #if !defined(ASIO_HAS_STD_CONCEPTS)
  239. # if !defined(ASIO_DISABLE_STD_CONCEPTS)
  240. # if defined(ASIO_HAS_CONCEPTS)
  241. # if (__cpp_lib_concepts >= 202002L)
  242. # define ASIO_HAS_STD_CONCEPTS 1
  243. # endif // (__cpp_concepts >= 202002L)
  244. # endif // defined(ASIO_HAS_CONCEPTS)
  245. # endif // !defined(ASIO_DISABLE_STD_CONCEPTS)
  246. #endif // !defined(ASIO_HAS_STD_CONCEPTS)
  247. // Support template variables on compilers known to allow it.
  248. #if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
  249. # if !defined(ASIO_DISABLE_VARIABLE_TEMPLATES)
  250. # if defined(__clang__)
  251. # if (__cplusplus >= 201402)
  252. # if __has_feature(__cxx_variable_templates__)
  253. # define ASIO_HAS_VARIABLE_TEMPLATES 1
  254. # endif // __has_feature(__cxx_variable_templates__)
  255. # endif // (__cplusplus >= 201402)
  256. # elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
  257. # if (__GNUC__ >= 6)
  258. # if (__cplusplus >= 201402)
  259. # define ASIO_HAS_VARIABLE_TEMPLATES 1
  260. # endif // (__cplusplus >= 201402)
  261. # endif // (__GNUC__ >= 6)
  262. # endif // defined(__GNUC__) && !defined(__INTEL_COMPILER)
  263. # if defined(ASIO_MSVC)
  264. # if (_MSC_VER >= 1901)
  265. # define ASIO_HAS_VARIABLE_TEMPLATES 1
  266. # endif // (_MSC_VER >= 1901)
  267. # endif // defined(ASIO_MSVC)
  268. # endif // !defined(ASIO_DISABLE_VARIABLE_TEMPLATES)
  269. #endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
  270. // Support SFINAEd template variables on compilers known to allow it.
  271. #if !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  272. # if !defined(ASIO_DISABLE_SFINAE_VARIABLE_TEMPLATES)
  273. # if defined(__clang__)
  274. # if (__cplusplus >= 201703)
  275. # if __has_feature(__cxx_variable_templates__)
  276. # define ASIO_HAS_SFINAE_VARIABLE_TEMPLATES 1
  277. # endif // __has_feature(__cxx_variable_templates__)
  278. # endif // (__cplusplus >= 201703)
  279. # elif defined(__GNUC__)
  280. # if ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 8)
  281. # if (__cplusplus >= 201402)
  282. # define ASIO_HAS_SFINAE_VARIABLE_TEMPLATES 1
  283. # endif // (__cplusplus >= 201402)
  284. # endif // ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 8)
  285. # endif // defined(__GNUC__)
  286. # if defined(ASIO_MSVC)
  287. # if (_MSC_VER >= 1901)
  288. # define ASIO_HAS_SFINAE_VARIABLE_TEMPLATES 1
  289. # endif // (_MSC_VER >= 1901)
  290. # endif // defined(ASIO_MSVC)
  291. # endif // !defined(ASIO_DISABLE_SFINAE_VARIABLE_TEMPLATES)
  292. #endif // !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  293. // Support SFINAE use of constant expressions on compilers known to allow it.
  294. #if !defined(ASIO_HAS_CONSTANT_EXPRESSION_SFINAE)
  295. # if !defined(ASIO_DISABLE_CONSTANT_EXPRESSION_SFINAE)
  296. # if defined(__clang__)
  297. # if (__cplusplus >= 201402)
  298. # define ASIO_HAS_CONSTANT_EXPRESSION_SFINAE 1
  299. # endif // (__cplusplus >= 201402)
  300. # elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
  301. # if (__GNUC__ >= 7)
  302. # if (__cplusplus >= 201402)
  303. # define ASIO_HAS_CONSTANT_EXPRESSION_SFINAE 1
  304. # endif // (__cplusplus >= 201402)
  305. # endif // (__GNUC__ >= 7)
  306. # endif // defined(__GNUC__) && !defined(__INTEL_COMPILER)
  307. # if defined(ASIO_MSVC)
  308. # if (_MSC_VER >= 1901)
  309. # define ASIO_HAS_CONSTANT_EXPRESSION_SFINAE 1
  310. # endif // (_MSC_VER >= 1901)
  311. # endif // defined(ASIO_MSVC)
  312. # endif // !defined(ASIO_DISABLE_CONSTANT_EXPRESSION_SFINAE)
  313. #endif // !defined(ASIO_HAS_CONSTANT_EXPRESSION_SFINAE)
  314. // Enable workarounds for lack of working expression SFINAE.
  315. #if !defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  316. # if !defined(ASIO_DISABLE_WORKING_EXPRESSION_SFINAE)
  317. # if !defined(ASIO_MSVC) && !defined(__INTEL_COMPILER)
  318. # if (__cplusplus >= 201103)
  319. # define ASIO_HAS_WORKING_EXPRESSION_SFINAE 1
  320. # endif // (__cplusplus >= 201103)
  321. # elif defined(ASIO_MSVC) && (_MSC_VER >= 1929)
  322. # if (_MSVC_LANG >= 202000)
  323. # define ASIO_HAS_WORKING_EXPRESSION_SFINAE 1
  324. # endif // (_MSVC_LANG >= 202000)
  325. # endif // defined(ASIO_MSVC) && (_MSC_VER >= 1929)
  326. # endif // !defined(ASIO_DISABLE_WORKING_EXPRESSION_SFINAE)
  327. #endif // !defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  328. // Support for capturing parameter packs in lambdas.
  329. #if !defined(ASIO_HAS_VARIADIC_LAMBDA_CAPTURES)
  330. # if !defined(ASIO_DISABLE_VARIADIC_LAMBDA_CAPTURES)
  331. # if defined(__GNUC__)
  332. # if (__GNUC__ >= 6)
  333. # define ASIO_HAS_VARIADIC_LAMBDA_CAPTURES 1
  334. # endif // (__GNUC__ >= 6)
  335. # elif defined(ASIO_MSVC)
  336. # if (_MSVC_LANG >= 201103)
  337. # define ASIO_HAS_VARIADIC_LAMBDA_CAPTURES 1
  338. # endif // (_MSC_LANG >= 201103)
  339. # else // defined(ASIO_MSVC)
  340. # if (__cplusplus >= 201103)
  341. # define ASIO_HAS_VARIADIC_LAMBDA_CAPTURES 1
  342. # endif // (__cplusplus >= 201103)
  343. # endif // defined(ASIO_MSVC)
  344. # endif // !defined(ASIO_DISABLE_VARIADIC_LAMBDA_CAPTURES)
  345. #endif // !defined(ASIO_HAS_VARIADIC_LAMBDA_CAPTURES)
  346. // Default alignment.
  347. #if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
  348. # define ASIO_DEFAULT_ALIGN __STDCPP_DEFAULT_NEW_ALIGNMENT__
  349. #elif defined(__GNUC__)
  350. # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
  351. # define ASIO_DEFAULT_ALIGN alignof(std::max_align_t)
  352. # else // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
  353. # define ASIO_DEFAULT_ALIGN alignof(max_align_t)
  354. # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
  355. #else // defined(__GNUC__)
  356. # define ASIO_DEFAULT_ALIGN alignof(std::max_align_t)
  357. #endif // defined(__GNUC__)
  358. // Standard library support for aligned allocation.
  359. #if !defined(ASIO_HAS_STD_ALIGNED_ALLOC)
  360. # if !defined(ASIO_DISABLE_STD_ALIGNED_ALLOC)
  361. # if (__cplusplus >= 201703)
  362. # if defined(__clang__)
  363. # if defined(ASIO_HAS_CLANG_LIBCXX)
  364. # if (_LIBCPP_STD_VER > 14) && defined(_LIBCPP_HAS_ALIGNED_ALLOC) \
  365. && !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__)
  366. # if defined(__APPLE__)
  367. # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  368. # if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
  369. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  370. # endif // (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
  371. # elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
  372. # if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
  373. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  374. # endif // (__IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
  375. # elif defined(__TV_OS_VERSION_MIN_REQUIRED)
  376. # if (__TV_OS_VERSION_MIN_REQUIRED >= 130000)
  377. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  378. # endif // (__TV_OS_VERSION_MIN_REQUIRED >= 130000)
  379. # elif defined(__WATCH_OS_VERSION_MIN_REQUIRED)
  380. # if (__WATCH_OS_VERSION_MIN_REQUIRED >= 60000)
  381. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  382. # endif // (__WATCH_OS_VERSION_MIN_REQUIRED >= 60000)
  383. # endif // defined(__WATCH_OS_X_VERSION_MIN_REQUIRED)
  384. # else // defined(__APPLE__)
  385. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  386. # endif // defined(__APPLE__)
  387. # endif // (_LIBCPP_STD_VER > 14) && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
  388. // && !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__)
  389. # elif defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)
  390. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  391. # endif // defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)
  392. # elif defined(__GNUC__)
  393. # if ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 7)
  394. # if defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)
  395. # define ASIO_HAS_STD_ALIGNED_ALLOC 1
  396. # endif // defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)
  397. # endif // ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 7)
  398. # endif // defined(__GNUC__)
  399. # endif // (__cplusplus >= 201703)
  400. # endif // !defined(ASIO_DISABLE_STD_ALIGNED_ALLOC)
  401. #endif // !defined(ASIO_HAS_STD_ALIGNED_ALLOC)
  402. // Boost support for chrono.
  403. #if !defined(ASIO_HAS_BOOST_CHRONO)
  404. # if !defined(ASIO_DISABLE_BOOST_CHRONO)
  405. # if defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 104700)
  406. # define ASIO_HAS_BOOST_CHRONO 1
  407. # endif // defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 104700)
  408. # endif // !defined(ASIO_DISABLE_BOOST_CHRONO)
  409. #endif // !defined(ASIO_HAS_BOOST_CHRONO)
  410. // Some form of chrono library is available.
  411. #if !defined(ASIO_HAS_CHRONO)
  412. # if defined(ASIO_HAS_STD_CHRONO) \
  413. || defined(ASIO_HAS_BOOST_CHRONO)
  414. # define ASIO_HAS_CHRONO 1
  415. # endif // defined(ASIO_HAS_STD_CHRONO)
  416. // || defined(ASIO_HAS_BOOST_CHRONO)
  417. #endif // !defined(ASIO_HAS_CHRONO)
  418. // Boost support for the DateTime library.
  419. #if !defined(ASIO_HAS_BOOST_DATE_TIME)
  420. # if !defined(ASIO_DISABLE_BOOST_DATE_TIME)
  421. # define ASIO_HAS_BOOST_DATE_TIME 1
  422. # endif // !defined(ASIO_DISABLE_BOOST_DATE_TIME)
  423. #endif // !defined(ASIO_HAS_BOOST_DATE_TIME)
  424. // Boost support for the Coroutine library.
  425. #if !defined(ASIO_HAS_BOOST_COROUTINE)
  426. # if !defined(ASIO_DISABLE_BOOST_COROUTINE)
  427. # define ASIO_HAS_BOOST_COROUTINE 1
  428. # endif // !defined(ASIO_DISABLE_BOOST_COROUTINE)
  429. #endif // !defined(ASIO_HAS_BOOST_COROUTINE)
  430. // Boost support for the Context library's fibers.
  431. #if !defined(ASIO_HAS_BOOST_CONTEXT_FIBER)
  432. # if !defined(ASIO_DISABLE_BOOST_CONTEXT_FIBER)
  433. # if defined(__clang__)
  434. # if (__cplusplus >= 201103)
  435. # define ASIO_HAS_BOOST_CONTEXT_FIBER 1
  436. # endif // (__cplusplus >= 201103)
  437. # elif defined(__GNUC__)
  438. # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4)
  439. # if (__cplusplus >= 201103) || defined(__GXX_EXPERIMENTAL_CXX0X__)
  440. # define ASIO_HAS_BOOST_CONTEXT_FIBER 1
  441. # endif // (__cplusplus >= 201103) || defined(__GXX_EXPERIMENTAL_CXX0X__)
  442. # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4)
  443. # endif // defined(__GNUC__)
  444. # if defined(ASIO_MSVC)
  445. # if (_MSVC_LANG >= 201103)
  446. # define ASIO_HAS_BOOST_CONTEXT_FIBER 1
  447. # endif // (_MSC_LANG >= 201103)
  448. # endif // defined(ASIO_MSVC)
  449. # endif // !defined(ASIO_DISABLE_BOOST_CONTEXT_FIBER)
  450. #endif // !defined(ASIO_HAS_BOOST_CONTEXT_FIBER)
  451. // Standard library support for std::string_view.
  452. #if !defined(ASIO_HAS_STD_STRING_VIEW)
  453. # if !defined(ASIO_DISABLE_STD_STRING_VIEW)
  454. # if defined(__clang__)
  455. # if defined(ASIO_HAS_CLANG_LIBCXX)
  456. # if (__cplusplus >= 201402)
  457. # if __has_include(<string_view>)
  458. # define ASIO_HAS_STD_STRING_VIEW 1
  459. # endif // __has_include(<string_view>)
  460. # endif // (__cplusplus >= 201402)
  461. # else // defined(ASIO_HAS_CLANG_LIBCXX)
  462. # if (__cplusplus >= 201703)
  463. # if __has_include(<string_view>)
  464. # define ASIO_HAS_STD_STRING_VIEW 1
  465. # endif // __has_include(<string_view>)
  466. # endif // (__cplusplus >= 201703)
  467. # endif // defined(ASIO_HAS_CLANG_LIBCXX)
  468. # elif defined(__GNUC__)
  469. # if (__GNUC__ >= 7)
  470. # if (__cplusplus >= 201703)
  471. # define ASIO_HAS_STD_STRING_VIEW 1
  472. # endif // (__cplusplus >= 201703)
  473. # endif // (__GNUC__ >= 7)
  474. # elif defined(ASIO_MSVC)
  475. # if (_MSC_VER >= 1910 && _MSVC_LANG >= 201703)
  476. # define ASIO_HAS_STD_STRING_VIEW 1
  477. # endif // (_MSC_VER >= 1910 && _MSVC_LANG >= 201703)
  478. # endif // defined(ASIO_MSVC)
  479. # endif // !defined(ASIO_DISABLE_STD_STRING_VIEW)
  480. #endif // !defined(ASIO_HAS_STD_STRING_VIEW)
  481. // Standard library support for std::experimental::string_view.
  482. #if !defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  483. # if !defined(ASIO_DISABLE_STD_EXPERIMENTAL_STRING_VIEW)
  484. # if defined(__clang__)
  485. # if defined(ASIO_HAS_CLANG_LIBCXX)
  486. # if (_LIBCPP_VERSION < 7000)
  487. # if (__cplusplus >= 201402)
  488. # if __has_include(<experimental/string_view>)
  489. # define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
  490. # endif // __has_include(<experimental/string_view>)
  491. # endif // (__cplusplus >= 201402)
  492. # endif // (_LIBCPP_VERSION < 7000)
  493. # else // defined(ASIO_HAS_CLANG_LIBCXX)
  494. # if (__cplusplus >= 201402)
  495. # if __has_include(<experimental/string_view>)
  496. # define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
  497. # endif // __has_include(<experimental/string_view>)
  498. # endif // (__cplusplus >= 201402)
  499. # endif // // defined(ASIO_HAS_CLANG_LIBCXX)
  500. # elif defined(__GNUC__)
  501. # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
  502. # if (__cplusplus >= 201402)
  503. # define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
  504. # endif // (__cplusplus >= 201402)
  505. # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
  506. # endif // defined(__GNUC__)
  507. # endif // !defined(ASIO_DISABLE_STD_EXPERIMENTAL_STRING_VIEW)
  508. #endif // !defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  509. // Standard library has a string_view that we can use.
  510. #if !defined(ASIO_HAS_STRING_VIEW)
  511. # if !defined(ASIO_DISABLE_STRING_VIEW)
  512. # if defined(ASIO_HAS_STD_STRING_VIEW)
  513. # define ASIO_HAS_STRING_VIEW 1
  514. # elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  515. # define ASIO_HAS_STRING_VIEW 1
  516. # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  517. # endif // !defined(ASIO_DISABLE_STRING_VIEW)
  518. #endif // !defined(ASIO_HAS_STRING_VIEW)
  519. // Standard library has invoke_result (which supersedes result_of).
  520. #if !defined(ASIO_HAS_STD_INVOKE_RESULT)
  521. # if !defined(ASIO_DISABLE_STD_INVOKE_RESULT)
  522. # if defined(ASIO_MSVC)
  523. # if (_MSC_VER >= 1911 && _MSVC_LANG >= 201703)
  524. # define ASIO_HAS_STD_INVOKE_RESULT 1
  525. # endif // (_MSC_VER >= 1911 && _MSVC_LANG >= 201703)
  526. # else // defined(ASIO_MSVC)
  527. # if (__cplusplus >= 201703)
  528. # define ASIO_HAS_STD_INVOKE_RESULT 1
  529. # endif // (__cplusplus >= 201703)
  530. # endif // defined(ASIO_MSVC)
  531. # endif // !defined(ASIO_DISABLE_STD_INVOKE_RESULT)
  532. #endif // !defined(ASIO_HAS_STD_INVOKE_RESULT)
  533. // Standard library support for std::any.
  534. #if !defined(ASIO_HAS_STD_ANY)
  535. # if !defined(ASIO_DISABLE_STD_ANY)
  536. # if defined(__clang__)
  537. # if (__cplusplus >= 201703)
  538. # if __has_include(<any>)
  539. # define ASIO_HAS_STD_ANY 1
  540. # endif // __has_include(<any>)
  541. # endif // (__cplusplus >= 201703)
  542. # elif defined(__GNUC__)
  543. # if (__GNUC__ >= 7)
  544. # if (__cplusplus >= 201703)
  545. # define ASIO_HAS_STD_ANY 1
  546. # endif // (__cplusplus >= 201703)
  547. # endif // (__GNUC__ >= 7)
  548. # endif // defined(__GNUC__)
  549. # if defined(ASIO_MSVC)
  550. # if (_MSC_VER >= 1910) && (_MSVC_LANG >= 201703)
  551. # define ASIO_HAS_STD_ANY 1
  552. # endif // (_MSC_VER >= 1910) && (_MSVC_LANG >= 201703)
  553. # endif // defined(ASIO_MSVC)
  554. # endif // !defined(ASIO_DISABLE_STD_ANY)
  555. #endif // !defined(ASIO_HAS_STD_ANY)
  556. // Standard library support for std::variant.
  557. #if !defined(ASIO_HAS_STD_VARIANT)
  558. # if !defined(ASIO_DISABLE_STD_VARIANT)
  559. # if defined(__clang__)
  560. # if (__cplusplus >= 201703)
  561. # if __has_include(<variant>)
  562. # define ASIO_HAS_STD_VARIANT 1
  563. # endif // __has_include(<variant>)
  564. # endif // (__cplusplus >= 201703)
  565. # elif defined(__GNUC__)
  566. # if (__GNUC__ >= 7)
  567. # if (__cplusplus >= 201703)
  568. # define ASIO_HAS_STD_VARIANT 1
  569. # endif // (__cplusplus >= 201703)
  570. # endif // (__GNUC__ >= 7)
  571. # endif // defined(__GNUC__)
  572. # if defined(ASIO_MSVC)
  573. # if (_MSC_VER >= 1910) && (_MSVC_LANG >= 201703)
  574. # define ASIO_HAS_STD_VARIANT 1
  575. # endif // (_MSC_VER >= 1910) && (_MSVC_LANG >= 201703)
  576. # endif // defined(ASIO_MSVC)
  577. # endif // !defined(ASIO_DISABLE_STD_VARIANT)
  578. #endif // !defined(ASIO_HAS_STD_VARIANT)
  579. // Standard library support for std::source_location.
  580. #if !defined(ASIO_HAS_STD_SOURCE_LOCATION)
  581. # if !defined(ASIO_DISABLE_STD_SOURCE_LOCATION)
  582. // ...
  583. # endif // !defined(ASIO_DISABLE_STD_SOURCE_LOCATION)
  584. #endif // !defined(ASIO_HAS_STD_SOURCE_LOCATION)
  585. // Standard library support for std::experimental::source_location.
  586. #if !defined(ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION)
  587. # if !defined(ASIO_DISABLE_STD_EXPERIMENTAL_SOURCE_LOCATION)
  588. # if defined(__GNUC__)
  589. # if (__cplusplus >= 201709)
  590. # if __has_include(<experimental/source_location>)
  591. # define ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION 1
  592. # endif // __has_include(<experimental/source_location>)
  593. # endif // (__cplusplus >= 201709)
  594. # endif // defined(__GNUC__)
  595. # endif // !defined(ASIO_DISABLE_STD_EXPERIMENTAL_SOURCE_LOCATION)
  596. #endif // !defined(ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION)
  597. // Standard library has a source_location that we can use.
  598. #if !defined(ASIO_HAS_SOURCE_LOCATION)
  599. # if !defined(ASIO_DISABLE_SOURCE_LOCATION)
  600. # if defined(ASIO_HAS_STD_SOURCE_LOCATION)
  601. # define ASIO_HAS_SOURCE_LOCATION 1
  602. # elif defined(ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION)
  603. # define ASIO_HAS_SOURCE_LOCATION 1
  604. # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_SOURCE_LOCATION)
  605. # endif // !defined(ASIO_DISABLE_SOURCE_LOCATION)
  606. #endif // !defined(ASIO_HAS_SOURCE_LOCATION)
  607. // Boost support for source_location and system errors.
  608. #if !defined(ASIO_HAS_BOOST_SOURCE_LOCATION)
  609. # if !defined(ASIO_DISABLE_BOOST_SOURCE_LOCATION)
  610. # if defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 107900)
  611. # define ASIO_HAS_BOOST_SOURCE_LOCATION 1
  612. # endif // defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 107900)
  613. # endif // !defined(ASIO_DISABLE_BOOST_SOURCE_LOCATION)
  614. #endif // !defined(ASIO_HAS_BOOST_SOURCE_LOCATION)
  615. // Helper macros for working with Boost source locations.
  616. #if defined(ASIO_HAS_BOOST_SOURCE_LOCATION)
  617. # define ASIO_SOURCE_LOCATION_PARAM \
  618. , const boost::source_location& loc
  619. # define ASIO_SOURCE_LOCATION_DEFAULTED_PARAM \
  620. , const boost::source_location& loc = BOOST_CURRENT_LOCATION
  621. # define ASIO_SOURCE_LOCATION_ARG , loc
  622. #else // if defined(ASIO_HAS_BOOST_SOURCE_LOCATION)
  623. # define ASIO_SOURCE_LOCATION_PARAM
  624. # define ASIO_SOURCE_LOCATION_DEFAULTED_PARAM
  625. # define ASIO_SOURCE_LOCATION_ARG
  626. #endif // if defined(ASIO_HAS_BOOST_SOURCE_LOCATION)
  627. // Standard library support for std::index_sequence.
  628. #if !defined(ASIO_HAS_STD_INDEX_SEQUENCE)
  629. # if !defined(ASIO_DISABLE_STD_INDEX_SEQUENCE)
  630. # if defined(__clang__)
  631. # if (__cplusplus >= 201402)
  632. # define ASIO_HAS_STD_INDEX_SEQUENCE 1
  633. # endif // (__cplusplus >= 201402)
  634. # elif defined(__GNUC__)
  635. # if (__GNUC__ >= 7)
  636. # if (__cplusplus >= 201402)
  637. # define ASIO_HAS_STD_INDEX_SEQUENCE 1
  638. # endif // (__cplusplus >= 201402)
  639. # endif // (__GNUC__ >= 7)
  640. # endif // defined(__GNUC__)
  641. # if defined(ASIO_MSVC)
  642. # if (_MSC_VER >= 1910) && (_MSVC_LANG >= 201402)
  643. # define ASIO_HAS_STD_INDEX_SEQUENCE 1
  644. # endif // (_MSC_VER >= 1910) && (_MSVC_LANG >= 201402)
  645. # endif // defined(ASIO_MSVC)
  646. # endif // !defined(ASIO_DISABLE_STD_INDEX_SEQUENCE)
  647. #endif // !defined(ASIO_HAS_STD_INDEX_SEQUENCE)
  648. // Windows App target. Windows but with a limited API.
  649. #if !defined(ASIO_WINDOWS_APP)
  650. # if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0603)
  651. # include <winapifamily.h>
  652. # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) \
  653. || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)) \
  654. && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  655. # define ASIO_WINDOWS_APP 1
  656. # endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
  657. // && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  658. # endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0603)
  659. #endif // !defined(ASIO_WINDOWS_APP)
  660. // Legacy WinRT target. Windows App is preferred.
  661. #if !defined(ASIO_WINDOWS_RUNTIME)
  662. # if !defined(ASIO_WINDOWS_APP)
  663. # if defined(__cplusplus_winrt)
  664. # include <winapifamily.h>
  665. # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) \
  666. && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  667. # define ASIO_WINDOWS_RUNTIME 1
  668. # endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
  669. // && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  670. # endif // defined(__cplusplus_winrt)
  671. # endif // !defined(ASIO_WINDOWS_APP)
  672. #endif // !defined(ASIO_WINDOWS_RUNTIME)
  673. // Windows target. Excludes WinRT but includes Windows App targets.
  674. #if !defined(ASIO_WINDOWS)
  675. # if !defined(ASIO_WINDOWS_RUNTIME)
  676. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS)
  677. # define ASIO_WINDOWS 1
  678. # elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  679. # define ASIO_WINDOWS 1
  680. # elif defined(ASIO_WINDOWS_APP)
  681. # define ASIO_WINDOWS 1
  682. # endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS)
  683. # endif // !defined(ASIO_WINDOWS_RUNTIME)
  684. #endif // !defined(ASIO_WINDOWS)
  685. // Windows: target OS version.
  686. #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  687. # if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
  688. # if defined(_MSC_VER) || (defined(__BORLANDC__) && !defined(__clang__))
  689. # pragma message( \
  690. "Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:\n"\
  691. "- add -D_WIN32_WINNT=0x0601 to the compiler command line; or\n"\
  692. "- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.\n"\
  693. "Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).")
  694. # else // defined(_MSC_VER) || (defined(__BORLANDC__) && !defined(__clang__))
  695. # warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately.
  696. # warning For example, add -D_WIN32_WINNT=0x0601 to the compiler command line.
  697. # warning Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
  698. # endif // defined(_MSC_VER) || (defined(__BORLANDC__) && !defined(__clang__))
  699. # define _WIN32_WINNT 0x0601
  700. # endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
  701. # if defined(_MSC_VER)
  702. # if defined(_WIN32) && !defined(WIN32)
  703. # if !defined(_WINSOCK2API_)
  704. # define WIN32 // Needed for correct types in winsock2.h
  705. # else // !defined(_WINSOCK2API_)
  706. # error Please define the macro WIN32 in your compiler options
  707. # endif // !defined(_WINSOCK2API_)
  708. # endif // defined(_WIN32) && !defined(WIN32)
  709. # endif // defined(_MSC_VER)
  710. # if defined(__BORLANDC__)
  711. # if defined(__WIN32__) && !defined(WIN32)
  712. # if !defined(_WINSOCK2API_)
  713. # define WIN32 // Needed for correct types in winsock2.h
  714. # else // !defined(_WINSOCK2API_)
  715. # error Please define the macro WIN32 in your compiler options
  716. # endif // !defined(_WINSOCK2API_)
  717. # endif // defined(__WIN32__) && !defined(WIN32)
  718. # endif // defined(__BORLANDC__)
  719. # if defined(__CYGWIN__)
  720. # if !defined(__USE_W32_SOCKETS)
  721. # error You must add -D__USE_W32_SOCKETS to your compiler options.
  722. # endif // !defined(__USE_W32_SOCKETS)
  723. # endif // defined(__CYGWIN__)
  724. #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  725. // Windows: minimise header inclusion.
  726. #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  727. # if !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
  728. # if !defined(WIN32_LEAN_AND_MEAN)
  729. # define WIN32_LEAN_AND_MEAN
  730. # endif // !defined(WIN32_LEAN_AND_MEAN)
  731. # endif // !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
  732. #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  733. // Windows: suppress definition of "min" and "max" macros.
  734. #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  735. # if !defined(ASIO_NO_NOMINMAX)
  736. # if !defined(NOMINMAX)
  737. # define NOMINMAX 1
  738. # endif // !defined(NOMINMAX)
  739. # endif // !defined(ASIO_NO_NOMINMAX)
  740. #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  741. // Windows: IO Completion Ports.
  742. #if !defined(ASIO_HAS_IOCP)
  743. # if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  744. # if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
  745. # if !defined(UNDER_CE) && !defined(ASIO_WINDOWS_APP)
  746. # if !defined(ASIO_DISABLE_IOCP)
  747. # define ASIO_HAS_IOCP 1
  748. # endif // !defined(ASIO_DISABLE_IOCP)
  749. # endif // !defined(UNDER_CE) && !defined(ASIO_WINDOWS_APP)
  750. # endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
  751. # endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  752. #endif // !defined(ASIO_HAS_IOCP)
  753. // On POSIX (and POSIX-like) platforms we need to include unistd.h in order to
  754. // get access to the various platform feature macros, e.g. to be able to test
  755. // for threads support.
  756. #if !defined(ASIO_HAS_UNISTD_H)
  757. # if !defined(ASIO_HAS_BOOST_CONFIG)
  758. # if defined(unix) \
  759. || defined(__unix) \
  760. || defined(_XOPEN_SOURCE) \
  761. || defined(_POSIX_SOURCE) \
  762. || (defined(__MACH__) && defined(__APPLE__)) \
  763. || defined(__FreeBSD__) \
  764. || defined(__NetBSD__) \
  765. || defined(__OpenBSD__) \
  766. || defined(__linux__) \
  767. || defined(__HAIKU__)
  768. # define ASIO_HAS_UNISTD_H 1
  769. # endif
  770. # endif // !defined(ASIO_HAS_BOOST_CONFIG)
  771. #endif // !defined(ASIO_HAS_UNISTD_H)
  772. #if defined(ASIO_HAS_UNISTD_H)
  773. # include <unistd.h>
  774. #endif // defined(ASIO_HAS_UNISTD_H)
  775. // Linux: epoll, eventfd, timerfd and io_uring.
  776. #if defined(__linux__)
  777. # include <linux/version.h>
  778. # if !defined(ASIO_HAS_EPOLL)
  779. # if !defined(ASIO_DISABLE_EPOLL)
  780. # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
  781. # define ASIO_HAS_EPOLL 1
  782. # endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
  783. # endif // !defined(ASIO_DISABLE_EPOLL)
  784. # endif // !defined(ASIO_HAS_EPOLL)
  785. # if !defined(ASIO_HAS_EVENTFD)
  786. # if !defined(ASIO_DISABLE_EVENTFD)
  787. # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
  788. # define ASIO_HAS_EVENTFD 1
  789. # endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
  790. # endif // !defined(ASIO_DISABLE_EVENTFD)
  791. # endif // !defined(ASIO_HAS_EVENTFD)
  792. # if !defined(ASIO_HAS_TIMERFD)
  793. # if defined(ASIO_HAS_EPOLL)
  794. # if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
  795. # define ASIO_HAS_TIMERFD 1
  796. # endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
  797. # endif // defined(ASIO_HAS_EPOLL)
  798. # endif // !defined(ASIO_HAS_TIMERFD)
  799. # if defined(ASIO_HAS_IO_URING)
  800. # if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
  801. # error Linux kernel 5.10 or later is required to support io_uring
  802. # endif // LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
  803. # endif // defined(ASIO_HAS_IO_URING)
  804. #endif // defined(__linux__)
  805. // Linux: io_uring is used instead of epoll.
  806. #if !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
  807. # if !defined(ASIO_HAS_EPOLL) && defined(ASIO_HAS_IO_URING)
  808. # define ASIO_HAS_IO_URING_AS_DEFAULT 1
  809. # endif // !defined(ASIO_HAS_EPOLL) && defined(ASIO_HAS_IO_URING)
  810. #endif // !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
  811. // Mac OS X, FreeBSD, NetBSD, OpenBSD: kqueue.
  812. #if (defined(__MACH__) && defined(__APPLE__)) \
  813. || defined(__FreeBSD__) \
  814. || defined(__NetBSD__) \
  815. || defined(__OpenBSD__)
  816. # if !defined(ASIO_HAS_KQUEUE)
  817. # if !defined(ASIO_DISABLE_KQUEUE)
  818. # define ASIO_HAS_KQUEUE 1
  819. # endif // !defined(ASIO_DISABLE_KQUEUE)
  820. # endif // !defined(ASIO_HAS_KQUEUE)
  821. #endif // (defined(__MACH__) && defined(__APPLE__))
  822. // || defined(__FreeBSD__)
  823. // || defined(__NetBSD__)
  824. // || defined(__OpenBSD__)
  825. // Solaris: /dev/poll.
  826. #if defined(__sun)
  827. # if !defined(ASIO_HAS_DEV_POLL)
  828. # if !defined(ASIO_DISABLE_DEV_POLL)
  829. # define ASIO_HAS_DEV_POLL 1
  830. # endif // !defined(ASIO_DISABLE_DEV_POLL)
  831. # endif // !defined(ASIO_HAS_DEV_POLL)
  832. #endif // defined(__sun)
  833. // Serial ports.
  834. #if !defined(ASIO_HAS_SERIAL_PORT)
  835. # if defined(ASIO_HAS_IOCP) \
  836. || !defined(ASIO_WINDOWS) \
  837. && !defined(ASIO_WINDOWS_RUNTIME) \
  838. && !defined(__CYGWIN__)
  839. # if !defined(__SYMBIAN32__)
  840. # if !defined(ASIO_DISABLE_SERIAL_PORT)
  841. # define ASIO_HAS_SERIAL_PORT 1
  842. # endif // !defined(ASIO_DISABLE_SERIAL_PORT)
  843. # endif // !defined(__SYMBIAN32__)
  844. # endif // defined(ASIO_HAS_IOCP)
  845. // || !defined(ASIO_WINDOWS)
  846. // && !defined(ASIO_WINDOWS_RUNTIME)
  847. // && !defined(__CYGWIN__)
  848. #endif // !defined(ASIO_HAS_SERIAL_PORT)
  849. // Windows: stream handles.
  850. #if !defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
  851. # if !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
  852. # if defined(ASIO_HAS_IOCP)
  853. # define ASIO_HAS_WINDOWS_STREAM_HANDLE 1
  854. # endif // defined(ASIO_HAS_IOCP)
  855. # endif // !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
  856. #endif // !defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
  857. // Windows: random access handles.
  858. #if !defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
  859. # if !defined(ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
  860. # if defined(ASIO_HAS_IOCP)
  861. # define ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE 1
  862. # endif // defined(ASIO_HAS_IOCP)
  863. # endif // !defined(ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
  864. #endif // !defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
  865. // Windows: object handles.
  866. #if !defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE)
  867. # if !defined(ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
  868. # if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  869. # if !defined(UNDER_CE) && !defined(ASIO_WINDOWS_APP)
  870. # define ASIO_HAS_WINDOWS_OBJECT_HANDLE 1
  871. # endif // !defined(UNDER_CE) && !defined(ASIO_WINDOWS_APP)
  872. # endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  873. # endif // !defined(ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
  874. #endif // !defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE)
  875. // Windows: OVERLAPPED wrapper.
  876. #if !defined(ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
  877. # if !defined(ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
  878. # if defined(ASIO_HAS_IOCP)
  879. # define ASIO_HAS_WINDOWS_OVERLAPPED_PTR 1
  880. # endif // defined(ASIO_HAS_IOCP)
  881. # endif // !defined(ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
  882. #endif // !defined(ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
  883. // POSIX: stream-oriented file descriptors.
  884. #if !defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
  885. # if !defined(ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
  886. # if !defined(ASIO_WINDOWS) \
  887. && !defined(ASIO_WINDOWS_RUNTIME) \
  888. && !defined(__CYGWIN__)
  889. # define ASIO_HAS_POSIX_STREAM_DESCRIPTOR 1
  890. # endif // !defined(ASIO_WINDOWS)
  891. // && !defined(ASIO_WINDOWS_RUNTIME)
  892. // && !defined(__CYGWIN__)
  893. # endif // !defined(ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
  894. #endif // !defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
  895. // UNIX domain sockets.
  896. #if !defined(ASIO_HAS_LOCAL_SOCKETS)
  897. # if !defined(ASIO_DISABLE_LOCAL_SOCKETS)
  898. # if !defined(ASIO_WINDOWS_RUNTIME)
  899. # define ASIO_HAS_LOCAL_SOCKETS 1
  900. # endif // !defined(ASIO_WINDOWS_RUNTIME)
  901. # endif // !defined(ASIO_DISABLE_LOCAL_SOCKETS)
  902. #endif // !defined(ASIO_HAS_LOCAL_SOCKETS)
  903. // Files.
  904. #if !defined(ASIO_HAS_FILE)
  905. # if !defined(ASIO_DISABLE_FILE)
  906. # if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
  907. # define ASIO_HAS_FILE 1
  908. # elif defined(ASIO_HAS_IO_URING)
  909. # define ASIO_HAS_FILE 1
  910. # endif // defined(ASIO_HAS_IO_URING)
  911. # endif // !defined(ASIO_DISABLE_FILE)
  912. #endif // !defined(ASIO_HAS_FILE)
  913. // Pipes.
  914. #if !defined(ASIO_HAS_PIPE)
  915. # if defined(ASIO_HAS_IOCP) \
  916. || !defined(ASIO_WINDOWS) \
  917. && !defined(ASIO_WINDOWS_RUNTIME) \
  918. && !defined(__CYGWIN__)
  919. # if !defined(__SYMBIAN32__)
  920. # if !defined(ASIO_DISABLE_PIPE)
  921. # define ASIO_HAS_PIPE 1
  922. # endif // !defined(ASIO_DISABLE_PIPE)
  923. # endif // !defined(__SYMBIAN32__)
  924. # endif // defined(ASIO_HAS_IOCP)
  925. // || !defined(ASIO_WINDOWS)
  926. // && !defined(ASIO_WINDOWS_RUNTIME)
  927. // && !defined(__CYGWIN__)
  928. #endif // !defined(ASIO_HAS_PIPE)
  929. // Can use sigaction() instead of signal().
  930. #if !defined(ASIO_HAS_SIGACTION)
  931. # if !defined(ASIO_DISABLE_SIGACTION)
  932. # if !defined(ASIO_WINDOWS) \
  933. && !defined(ASIO_WINDOWS_RUNTIME) \
  934. && !defined(__CYGWIN__)
  935. # define ASIO_HAS_SIGACTION 1
  936. # endif // !defined(ASIO_WINDOWS)
  937. // && !defined(ASIO_WINDOWS_RUNTIME)
  938. // && !defined(__CYGWIN__)
  939. # endif // !defined(ASIO_DISABLE_SIGACTION)
  940. #endif // !defined(ASIO_HAS_SIGACTION)
  941. // Can use signal().
  942. #if !defined(ASIO_HAS_SIGNAL)
  943. # if !defined(ASIO_DISABLE_SIGNAL)
  944. # if !defined(UNDER_CE)
  945. # define ASIO_HAS_SIGNAL 1
  946. # endif // !defined(UNDER_CE)
  947. # endif // !defined(ASIO_DISABLE_SIGNAL)
  948. #endif // !defined(ASIO_HAS_SIGNAL)
  949. // Can use getaddrinfo() and getnameinfo().
  950. #if !defined(ASIO_HAS_GETADDRINFO)
  951. # if !defined(ASIO_DISABLE_GETADDRINFO)
  952. # if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  953. # if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501)
  954. # define ASIO_HAS_GETADDRINFO 1
  955. # elif defined(UNDER_CE)
  956. # define ASIO_HAS_GETADDRINFO 1
  957. # endif // defined(UNDER_CE)
  958. # elif defined(__MACH__) && defined(__APPLE__)
  959. # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  960. # if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
  961. # define ASIO_HAS_GETADDRINFO 1
  962. # endif // (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
  963. # else // defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  964. # define ASIO_HAS_GETADDRINFO 1
  965. # endif // defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  966. # else // defined(__MACH__) && defined(__APPLE__)
  967. # define ASIO_HAS_GETADDRINFO 1
  968. # endif // defined(__MACH__) && defined(__APPLE__)
  969. # endif // !defined(ASIO_DISABLE_GETADDRINFO)
  970. #endif // !defined(ASIO_HAS_GETADDRINFO)
  971. // Whether standard iostreams are disabled.
  972. #if !defined(ASIO_NO_IOSTREAM)
  973. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_IOSTREAM)
  974. # define ASIO_NO_IOSTREAM 1
  975. # endif // !defined(BOOST_NO_IOSTREAM)
  976. #endif // !defined(ASIO_NO_IOSTREAM)
  977. // Whether exception handling is disabled.
  978. #if !defined(ASIO_NO_EXCEPTIONS)
  979. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_EXCEPTIONS)
  980. # define ASIO_NO_EXCEPTIONS 1
  981. # endif // !defined(BOOST_NO_EXCEPTIONS)
  982. #endif // !defined(ASIO_NO_EXCEPTIONS)
  983. // Whether the typeid operator is supported.
  984. #if !defined(ASIO_NO_TYPEID)
  985. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_TYPEID)
  986. # define ASIO_NO_TYPEID 1
  987. # endif // !defined(BOOST_NO_TYPEID)
  988. #endif // !defined(ASIO_NO_TYPEID)
  989. // Threads.
  990. #if !defined(ASIO_HAS_THREADS)
  991. # if !defined(ASIO_DISABLE_THREADS)
  992. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_THREADS)
  993. # define ASIO_HAS_THREADS 1
  994. # elif defined(__GNUC__) && !defined(__MINGW32__) \
  995. && !defined(linux) && !defined(__linux) && !defined(__linux__)
  996. # define ASIO_HAS_THREADS 1
  997. # elif defined(_MT) || defined(__MT__)
  998. # define ASIO_HAS_THREADS 1
  999. # elif defined(_REENTRANT)
  1000. # define ASIO_HAS_THREADS 1
  1001. # elif defined(__APPLE__)
  1002. # define ASIO_HAS_THREADS 1
  1003. # elif defined(__HAIKU__)
  1004. # define ASIO_HAS_THREADS 1
  1005. # elif defined(_POSIX_THREADS) && (_POSIX_THREADS + 0 >= 0)
  1006. # define ASIO_HAS_THREADS 1
  1007. # elif defined(_PTHREADS)
  1008. # define ASIO_HAS_THREADS 1
  1009. # endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_THREADS)
  1010. # endif // !defined(ASIO_DISABLE_THREADS)
  1011. #endif // !defined(ASIO_HAS_THREADS)
  1012. // POSIX threads.
  1013. #if !defined(ASIO_HAS_PTHREADS)
  1014. # if defined(ASIO_HAS_THREADS)
  1015. # if defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_PTHREADS)
  1016. # define ASIO_HAS_PTHREADS 1
  1017. # elif defined(_POSIX_THREADS) && (_POSIX_THREADS + 0 >= 0)
  1018. # define ASIO_HAS_PTHREADS 1
  1019. # elif defined(__HAIKU__)
  1020. # define ASIO_HAS_PTHREADS 1
  1021. # endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_PTHREADS)
  1022. # endif // defined(ASIO_HAS_THREADS)
  1023. #endif // !defined(ASIO_HAS_PTHREADS)
  1024. // Helper to prevent macro expansion.
  1025. #define ASIO_PREVENT_MACRO_SUBSTITUTION
  1026. // Helper to define in-class constants.
  1027. #if !defined(ASIO_STATIC_CONSTANT)
  1028. # if !defined(ASIO_DISABLE_BOOST_STATIC_CONSTANT)
  1029. # define ASIO_STATIC_CONSTANT(type, assignment) \
  1030. BOOST_STATIC_CONSTANT(type, assignment)
  1031. # else // !defined(ASIO_DISABLE_BOOST_STATIC_CONSTANT)
  1032. # define ASIO_STATIC_CONSTANT(type, assignment) \
  1033. static const type assignment
  1034. # endif // !defined(ASIO_DISABLE_BOOST_STATIC_CONSTANT)
  1035. #endif // !defined(ASIO_STATIC_CONSTANT)
  1036. // Boost align library.
  1037. #if !defined(ASIO_HAS_BOOST_ALIGN)
  1038. # if !defined(ASIO_DISABLE_BOOST_ALIGN)
  1039. # if defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 105600)
  1040. # define ASIO_HAS_BOOST_ALIGN 1
  1041. # endif // defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 105600)
  1042. # endif // !defined(ASIO_DISABLE_BOOST_ALIGN)
  1043. #endif // !defined(ASIO_HAS_BOOST_ALIGN)
  1044. // Boost array library.
  1045. #if !defined(ASIO_HAS_BOOST_ARRAY)
  1046. # if !defined(ASIO_DISABLE_BOOST_ARRAY)
  1047. # define ASIO_HAS_BOOST_ARRAY 1
  1048. # endif // !defined(ASIO_DISABLE_BOOST_ARRAY)
  1049. #endif // !defined(ASIO_HAS_BOOST_ARRAY)
  1050. // Boost assert macro.
  1051. #if !defined(ASIO_HAS_BOOST_ASSERT)
  1052. # if !defined(ASIO_DISABLE_BOOST_ASSERT)
  1053. # define ASIO_HAS_BOOST_ASSERT 1
  1054. # endif // !defined(ASIO_DISABLE_BOOST_ASSERT)
  1055. #endif // !defined(ASIO_HAS_BOOST_ASSERT)
  1056. // Boost limits header.
  1057. #if !defined(ASIO_HAS_BOOST_LIMITS)
  1058. # if !defined(ASIO_DISABLE_BOOST_LIMITS)
  1059. # define ASIO_HAS_BOOST_LIMITS 1
  1060. # endif // !defined(ASIO_DISABLE_BOOST_LIMITS)
  1061. #endif // !defined(ASIO_HAS_BOOST_LIMITS)
  1062. // Boost throw_exception function.
  1063. #if !defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
  1064. # if !defined(ASIO_DISABLE_BOOST_THROW_EXCEPTION)
  1065. # define ASIO_HAS_BOOST_THROW_EXCEPTION 1
  1066. # endif // !defined(ASIO_DISABLE_BOOST_THROW_EXCEPTION)
  1067. #endif // !defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
  1068. // Boost regex library.
  1069. #if !defined(ASIO_HAS_BOOST_REGEX)
  1070. # if !defined(ASIO_DISABLE_BOOST_REGEX)
  1071. # define ASIO_HAS_BOOST_REGEX 1
  1072. # endif // !defined(ASIO_DISABLE_BOOST_REGEX)
  1073. #endif // !defined(ASIO_HAS_BOOST_REGEX)
  1074. // Boost bind function.
  1075. #if !defined(ASIO_HAS_BOOST_BIND)
  1076. # if !defined(ASIO_DISABLE_BOOST_BIND)
  1077. # define ASIO_HAS_BOOST_BIND 1
  1078. # endif // !defined(ASIO_DISABLE_BOOST_BIND)
  1079. #endif // !defined(ASIO_HAS_BOOST_BIND)
  1080. // Boost's BOOST_WORKAROUND macro.
  1081. #if !defined(ASIO_HAS_BOOST_WORKAROUND)
  1082. # if !defined(ASIO_DISABLE_BOOST_WORKAROUND)
  1083. # define ASIO_HAS_BOOST_WORKAROUND 1
  1084. # endif // !defined(ASIO_DISABLE_BOOST_WORKAROUND)
  1085. #endif // !defined(ASIO_HAS_BOOST_WORKAROUND)
  1086. // Microsoft Visual C++'s secure C runtime library.
  1087. #if !defined(ASIO_HAS_SECURE_RTL)
  1088. # if !defined(ASIO_DISABLE_SECURE_RTL)
  1089. # if defined(ASIO_MSVC) \
  1090. && (ASIO_MSVC >= 1400) \
  1091. && !defined(UNDER_CE)
  1092. # define ASIO_HAS_SECURE_RTL 1
  1093. # endif // defined(ASIO_MSVC)
  1094. // && (ASIO_MSVC >= 1400)
  1095. // && !defined(UNDER_CE)
  1096. # endif // !defined(ASIO_DISABLE_SECURE_RTL)
  1097. #endif // !defined(ASIO_HAS_SECURE_RTL)
  1098. // Handler hooking. Disabled for ancient Borland C++ and gcc compilers.
  1099. #if !defined(ASIO_HAS_HANDLER_HOOKS)
  1100. # if !defined(ASIO_DISABLE_HANDLER_HOOKS)
  1101. # if defined(__GNUC__)
  1102. # if (__GNUC__ >= 3)
  1103. # define ASIO_HAS_HANDLER_HOOKS 1
  1104. # endif // (__GNUC__ >= 3)
  1105. # elif !defined(__BORLANDC__) || defined(__clang__)
  1106. # define ASIO_HAS_HANDLER_HOOKS 1
  1107. # endif // !defined(__BORLANDC__) || defined(__clang__)
  1108. # endif // !defined(ASIO_DISABLE_HANDLER_HOOKS)
  1109. #endif // !defined(ASIO_HAS_HANDLER_HOOKS)
  1110. // Support for the __thread keyword extension, or equivalent.
  1111. #if !defined(ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
  1112. # if defined(__linux__)
  1113. # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
  1114. # if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
  1115. # if !defined(__INTEL_COMPILER) && !defined(__ICL) \
  1116. && !(defined(__clang__) && defined(__ANDROID__))
  1117. # define ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
  1118. # define ASIO_THREAD_KEYWORD __thread
  1119. # elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1100)
  1120. # define ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
  1121. # endif // defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1100)
  1122. // && !(defined(__clang__) && defined(__ANDROID__))
  1123. # endif // ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
  1124. # endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
  1125. # endif // defined(__linux__)
  1126. # if defined(ASIO_MSVC) && defined(ASIO_WINDOWS_RUNTIME)
  1127. # if (_MSC_VER >= 1700)
  1128. # define ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
  1129. # define ASIO_THREAD_KEYWORD __declspec(thread)
  1130. # endif // (_MSC_VER >= 1700)
  1131. # endif // defined(ASIO_MSVC) && defined(ASIO_WINDOWS_RUNTIME)
  1132. # if defined(__APPLE__)
  1133. # if defined(__clang__)
  1134. # if defined(__apple_build_version__)
  1135. # define ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
  1136. # define ASIO_THREAD_KEYWORD __thread
  1137. # endif // defined(__apple_build_version__)
  1138. # endif // defined(__clang__)
  1139. # endif // defined(__APPLE__)
  1140. # if !defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  1141. # if defined(ASIO_HAS_BOOST_CONFIG)
  1142. # if !defined(BOOST_NO_CXX11_THREAD_LOCAL)
  1143. # define ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
  1144. # define ASIO_THREAD_KEYWORD thread_local
  1145. # endif // !defined(BOOST_NO_CXX11_THREAD_LOCAL)
  1146. # endif // defined(ASIO_HAS_BOOST_CONFIG)
  1147. # endif // !defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
  1148. #endif // !defined(ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
  1149. #if !defined(ASIO_THREAD_KEYWORD)
  1150. # define ASIO_THREAD_KEYWORD __thread
  1151. #endif // !defined(ASIO_THREAD_KEYWORD)
  1152. // Support for POSIX ssize_t typedef.
  1153. #if !defined(ASIO_DISABLE_SSIZE_T)
  1154. # if defined(__linux__) \
  1155. || (defined(__MACH__) && defined(__APPLE__))
  1156. # define ASIO_HAS_SSIZE_T 1
  1157. # endif // defined(__linux__)
  1158. // || (defined(__MACH__) && defined(__APPLE__))
  1159. #endif // !defined(ASIO_DISABLE_SSIZE_T)
  1160. // Helper macros to manage transition away from error_code return values.
  1161. #if defined(ASIO_NO_DEPRECATED)
  1162. # define ASIO_SYNC_OP_VOID void
  1163. # define ASIO_SYNC_OP_VOID_RETURN(e) return
  1164. #else // defined(ASIO_NO_DEPRECATED)
  1165. # define ASIO_SYNC_OP_VOID asio::error_code
  1166. # define ASIO_SYNC_OP_VOID_RETURN(e) return e
  1167. #endif // defined(ASIO_NO_DEPRECATED)
  1168. // Newer gcc, clang need special treatment to suppress unused typedef warnings.
  1169. #if defined(__clang__)
  1170. # if defined(__apple_build_version__)
  1171. # if (__clang_major__ >= 7)
  1172. # define ASIO_UNUSED_TYPEDEF __attribute__((__unused__))
  1173. # endif // (__clang_major__ >= 7)
  1174. # elif ((__clang_major__ == 3) && (__clang_minor__ >= 6)) \
  1175. || (__clang_major__ > 3)
  1176. # define ASIO_UNUSED_TYPEDEF __attribute__((__unused__))
  1177. # endif // ((__clang_major__ == 3) && (__clang_minor__ >= 6))
  1178. // || (__clang_major__ > 3)
  1179. #elif defined(__GNUC__)
  1180. # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4)
  1181. # define ASIO_UNUSED_TYPEDEF __attribute__((__unused__))
  1182. # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4)
  1183. #endif // defined(__GNUC__)
  1184. #if !defined(ASIO_UNUSED_TYPEDEF)
  1185. # define ASIO_UNUSED_TYPEDEF
  1186. #endif // !defined(ASIO_UNUSED_TYPEDEF)
  1187. // Some versions of gcc generate spurious warnings about unused variables.
  1188. #if defined(__GNUC__)
  1189. # if (__GNUC__ >= 4)
  1190. # define ASIO_UNUSED_VARIABLE __attribute__((__unused__))
  1191. # endif // (__GNUC__ >= 4)
  1192. #endif // defined(__GNUC__)
  1193. #if !defined(ASIO_UNUSED_VARIABLE)
  1194. # define ASIO_UNUSED_VARIABLE
  1195. #endif // !defined(ASIO_UNUSED_VARIABLE)
  1196. // Helper macro to tell the optimiser what may be assumed to be true.
  1197. #if defined(ASIO_MSVC)
  1198. # define ASIO_ASSUME(expr) __assume(expr)
  1199. #elif defined(__clang__)
  1200. # if __has_builtin(__builtin_assume)
  1201. # define ASIO_ASSUME(expr) __builtin_assume(expr)
  1202. # endif // __has_builtin(__builtin_assume)
  1203. #elif defined(__GNUC__)
  1204. # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
  1205. # define ASIO_ASSUME(expr) if (expr) {} else { __builtin_unreachable(); }
  1206. # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
  1207. #endif // defined(__GNUC__)
  1208. #if !defined(ASIO_ASSUME)
  1209. # define ASIO_ASSUME(expr) (void)0
  1210. #endif // !defined(ASIO_ASSUME)
  1211. // Support the co_await keyword on compilers known to allow it.
  1212. #if !defined(ASIO_HAS_CO_AWAIT)
  1213. # if !defined(ASIO_DISABLE_CO_AWAIT)
  1214. # if defined(ASIO_MSVC)
  1215. # if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705) && !defined(__clang__)
  1216. # define ASIO_HAS_CO_AWAIT 1
  1217. # elif (_MSC_FULL_VER >= 190023506)
  1218. # if defined(_RESUMABLE_FUNCTIONS_SUPPORTED)
  1219. # define ASIO_HAS_CO_AWAIT 1
  1220. # endif // defined(_RESUMABLE_FUNCTIONS_SUPPORTED)
  1221. # endif // (_MSC_FULL_VER >= 190023506)
  1222. # elif defined(__clang__)
  1223. # if (__clang_major__ >= 14)
  1224. # if (__cplusplus >= 202002) && (__cpp_impl_coroutine >= 201902)
  1225. # if __has_include(<coroutine>)
  1226. # define ASIO_HAS_CO_AWAIT 1
  1227. # endif // __has_include(<coroutine>)
  1228. # elif (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
  1229. # if __has_include(<experimental/coroutine>)
  1230. # define ASIO_HAS_CO_AWAIT 1
  1231. # endif // __has_include(<experimental/coroutine>)
  1232. # endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
  1233. # else // (__clang_major__ >= 14)
  1234. # if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
  1235. # if __has_include(<experimental/coroutine>)
  1236. # define ASIO_HAS_CO_AWAIT 1
  1237. # endif // __has_include(<experimental/coroutine>)
  1238. # endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
  1239. # endif // (__clang_major__ >= 14)
  1240. # elif defined(__GNUC__)
  1241. # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
  1242. # if __has_include(<coroutine>)
  1243. # define ASIO_HAS_CO_AWAIT 1
  1244. # endif // __has_include(<coroutine>)
  1245. # endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
  1246. # endif // defined(__GNUC__)
  1247. # endif // !defined(ASIO_DISABLE_CO_AWAIT)
  1248. #endif // !defined(ASIO_HAS_CO_AWAIT)
  1249. // Standard library support for coroutines.
  1250. #if !defined(ASIO_HAS_STD_COROUTINE)
  1251. # if !defined(ASIO_DISABLE_STD_COROUTINE)
  1252. # if defined(ASIO_MSVC)
  1253. # if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705)
  1254. # define ASIO_HAS_STD_COROUTINE 1
  1255. # endif // (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705)
  1256. # elif defined(__clang__)
  1257. # if (__clang_major__ >= 14)
  1258. # if (__cplusplus >= 202002) && (__cpp_impl_coroutine >= 201902)
  1259. # if __has_include(<coroutine>)
  1260. # define ASIO_HAS_STD_COROUTINE 1
  1261. # endif // __has_include(<coroutine>)
  1262. # endif // (__cplusplus >= 202002) && (__cpp_impl_coroutine >= 201902)
  1263. # endif // (__clang_major__ >= 14)
  1264. # elif defined(__GNUC__)
  1265. # if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
  1266. # if __has_include(<coroutine>)
  1267. # define ASIO_HAS_STD_COROUTINE 1
  1268. # endif // __has_include(<coroutine>)
  1269. # endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
  1270. # endif // defined(__GNUC__)
  1271. # endif // !defined(ASIO_DISABLE_STD_COROUTINE)
  1272. #endif // !defined(ASIO_HAS_STD_COROUTINE)
  1273. // Compiler support for the the [[nodiscard]] attribute.
  1274. #if !defined(ASIO_NODISCARD)
  1275. # if defined(__has_cpp_attribute)
  1276. # if __has_cpp_attribute(nodiscard)
  1277. # if (__cplusplus >= 201703)
  1278. # define ASIO_NODISCARD [[nodiscard]]
  1279. # endif // (__cplusplus >= 201703)
  1280. # endif // __has_cpp_attribute(nodiscard)
  1281. # endif // defined(__has_cpp_attribute)
  1282. #endif // !defined(ASIO_NODISCARD)
  1283. #if !defined(ASIO_NODISCARD)
  1284. # define ASIO_NODISCARD
  1285. #endif // !defined(ASIO_NODISCARD)
  1286. // Kernel support for MSG_NOSIGNAL.
  1287. #if !defined(ASIO_HAS_MSG_NOSIGNAL)
  1288. # if defined(__linux__)
  1289. # define ASIO_HAS_MSG_NOSIGNAL 1
  1290. # elif defined(_POSIX_VERSION)
  1291. # if (_POSIX_VERSION >= 200809L)
  1292. # define ASIO_HAS_MSG_NOSIGNAL 1
  1293. # endif // _POSIX_VERSION >= 200809L
  1294. # endif // defined(_POSIX_VERSION)
  1295. #endif // !defined(ASIO_HAS_MSG_NOSIGNAL)
  1296. // Standard library support for std::to_address.
  1297. #if !defined(ASIO_HAS_STD_TO_ADDRESS)
  1298. # if !defined(ASIO_DISABLE_STD_TO_ADDRESS)
  1299. # if defined(__clang__)
  1300. # if (__cplusplus >= 202002)
  1301. # define ASIO_HAS_STD_TO_ADDRESS 1
  1302. # endif // (__cplusplus >= 202002)
  1303. # elif defined(__GNUC__)
  1304. # if (__GNUC__ >= 8)
  1305. # if (__cplusplus >= 202002)
  1306. # define ASIO_HAS_STD_TO_ADDRESS 1
  1307. # endif // (__cplusplus >= 202002)
  1308. # endif // (__GNUC__ >= 8)
  1309. # endif // defined(__GNUC__)
  1310. # if defined(ASIO_MSVC)
  1311. # if (_MSC_VER >= 1922) && (_MSVC_LANG >= 202002)
  1312. # define ASIO_HAS_STD_TO_ADDRESS 1
  1313. # endif // (_MSC_VER >= 1922) && (_MSVC_LANG >= 202002)
  1314. # endif // defined(ASIO_MSVC)
  1315. # endif // !defined(ASIO_DISABLE_STD_TO_ADDRESS)
  1316. #endif // !defined(ASIO_HAS_STD_TO_ADDRESS)
  1317. // Standard library support for snprintf.
  1318. #if !defined(ASIO_HAS_SNPRINTF)
  1319. # if !defined(ASIO_DISABLE_SNPRINTF)
  1320. # if defined(__apple_build_version__)
  1321. # if (__clang_major__ >= 14)
  1322. # define ASIO_HAS_SNPRINTF 1
  1323. # endif // (__clang_major__ >= 14)
  1324. # endif // defined(__apple_build_version__)
  1325. # endif // !defined(ASIO_DISABLE_SNPRINTF)
  1326. #endif // !defined(ASIO_HAS_SNPRINTF)
  1327. #endif // ASIO_DETAIL_CONFIG_HPP