wistd_config.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. // -*- C++ -*-
  2. //===--------------------------- __config ---------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. // STL common functionality
  11. //
  12. // Some aspects of STL are core language concepts that should be used from all C++ code, regardless
  13. // of whether exceptions are enabled in the component. Common library code that expects to be used
  14. // from exception-free components want these concepts, but including STL headers directly introduces
  15. // friction as it requires components not using STL to declare their STL version. Doing so creates
  16. // ambiguity around whether STL use is safe in a particular component and implicitly brings in
  17. // a long list of headers (including <new>) which can create further ambiguity around throwing new
  18. // support (some routines pulled in may expect it). Secondarily, pulling in these headers also has
  19. // the potential to create naming conflicts or other implied dependencies.
  20. //
  21. // To promote the use of these core language concepts outside of STL-based binaries, this file is
  22. // selectively pulling those concepts *directly* from corresponding STL headers. The corresponding
  23. // "std::" namespace STL functions and types should be preferred over these in code that is bound to
  24. // STL. The implementation and naming of all functions are taken directly from STL, instead using
  25. // "wistd" (Windows Implementation std) as the namespace.
  26. //
  27. // Routines in this namespace should always be considered a reflection of the *current* STL implementation
  28. // of those routines. Updates from STL should be taken, but no "bugs" should be fixed here.
  29. //
  30. // New, exception-based code should not use this namespace, but instead should prefer the std:: implementation.
  31. // Only code that is not exception-based and libraries that expect to be utilized across both exception
  32. // and non-exception based code should utilize this functionality.
  33. // This header mimics libc++'s '__config' header to the extent necessary to get the wistd::* definitions compiling. Note
  34. // that this has a few key differences since libc++'s MSVC compatability is currently not functional and a bit behind
  35. #ifndef _WISTD_CONFIG_H_
  36. #define _WISTD_CONFIG_H_
  37. // DO NOT add *any* additional includes to this file -- there should be no dependencies from its usage
  38. #include <cstddef> // For size_t and other necessary types
  39. /// @cond
  40. #if defined(_MSC_VER) && !defined(__clang__)
  41. # if !defined(__WI_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  42. # define __WI_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  43. # endif
  44. #endif
  45. #ifndef __WI_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  46. #pragma GCC system_header
  47. #endif
  48. #ifdef __GNUC__
  49. # define __WI_GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
  50. // The __WI_GNUC_VER_NEW macro better represents the new GCC versioning scheme
  51. // introduced in GCC 5.0.
  52. # define __WI_GNUC_VER_NEW (__WI_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
  53. #else
  54. # define __WI_GNUC_VER 0
  55. # define __WI_GNUC_VER_NEW 0
  56. #endif
  57. // _MSVC_LANG is the more accurate way to get the C++ version in MSVC
  58. #if defined(_MSVC_LANG) && (_MSVC_LANG > __cplusplus)
  59. #define __WI_CPLUSPLUS _MSVC_LANG
  60. #else
  61. #define __WI_CPLUSPLUS __cplusplus
  62. #endif
  63. #ifndef __WI_LIBCPP_STD_VER
  64. # if __WI_CPLUSPLUS <= 201103L
  65. # define __WI_LIBCPP_STD_VER 11
  66. # elif __WI_CPLUSPLUS <= 201402L
  67. # define __WI_LIBCPP_STD_VER 14
  68. # elif __WI_CPLUSPLUS <= 201703L
  69. # define __WI_LIBCPP_STD_VER 17
  70. # else
  71. # define __WI_LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
  72. # endif
  73. #endif // __WI_LIBCPP_STD_VER
  74. #if __WI_CPLUSPLUS < 201103L
  75. #define __WI_LIBCPP_CXX03_LANG
  76. #endif
  77. #if defined(__ELF__)
  78. # define __WI_LIBCPP_OBJECT_FORMAT_ELF 1
  79. #elif defined(__MACH__)
  80. # define __WI_LIBCPP_OBJECT_FORMAT_MACHO 1
  81. #elif defined(_WIN32)
  82. # define __WI_LIBCPP_OBJECT_FORMAT_COFF 1
  83. #elif defined(__wasm__)
  84. # define __WI_LIBCPP_OBJECT_FORMAT_WASM 1
  85. #else
  86. # error Unknown object file format
  87. #endif
  88. #if defined(__clang__)
  89. # define __WI_LIBCPP_COMPILER_CLANG
  90. #elif defined(__GNUC__)
  91. # define __WI_LIBCPP_COMPILER_GCC
  92. #elif defined(_MSC_VER)
  93. # define __WI_LIBCPP_COMPILER_MSVC
  94. #elif defined(__IBMCPP__)
  95. # define __WI_LIBCPP_COMPILER_IBM
  96. #endif
  97. #if defined(__WI_LIBCPP_COMPILER_MSVC)
  98. #define __WI_PUSH_WARNINGS __pragma(warning(push))
  99. #define __WI_POP_WARNINGS __pragma(warning(pop))
  100. #elif defined(__WI_LIBCPP_COMPILER_CLANG)
  101. #define __WI_PUSH_WARNINGS __pragma(clang diagnostic push)
  102. #define __WI_POP_WARNINGS __pragma(clang diagnostic pop)
  103. #else
  104. #define __WI_PUSH_WARNINGS
  105. #define __WI_POP_WARNINGS
  106. #endif
  107. #ifdef __WI_LIBCPP_COMPILER_MSVC
  108. #define __WI_MSVC_DISABLE_WARNING(id) __pragma(warning(disable: id))
  109. #else
  110. #define __WI_MSVC_DISABLE_WARNING(id)
  111. #endif
  112. #ifdef __WI_LIBCPP_COMPILER_CLANG
  113. #define __WI_CLANG_DISABLE_WARNING(warning) __pragma(clang diagnostic ignored #warning)
  114. #else
  115. #define __WI_CLANG_DISABLE_WARNING(warning)
  116. #endif
  117. // NOTE: MSVC, which is what we primarily target, is severly underrepresented in libc++ and checks such as
  118. // __has_feature(...) are always false for MSVC, even when the feature being tested _is_ present in MSVC. Therefore, we
  119. // instead modify all checks to be __WI_HAS_FEATURE_IS_UNION, etc., which provides the correct value for MSVC and falls
  120. // back to the __has_feature(...), etc. value otherwise. We intentionally leave '__has_feature', etc. undefined for MSVC
  121. // so that we don't accidentally use the incorrect behavior
  122. #ifndef __WI_LIBCPP_COMPILER_MSVC
  123. #ifndef __has_feature
  124. #define __has_feature(__x) 0
  125. #endif
  126. // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
  127. // the compiler and '1' otherwise.
  128. #ifndef __is_identifier
  129. #define __is_identifier(__x) 1
  130. #endif
  131. #ifndef __has_cpp_attribute
  132. #define __has_cpp_attribute(__x) 0
  133. #endif
  134. #ifndef __has_attribute
  135. #define __has_attribute(__x) 0
  136. #endif
  137. #ifndef __has_builtin
  138. #define __has_builtin(__x) 0
  139. #endif
  140. #if __has_feature(cxx_alignas)
  141. # define __WI_ALIGNAS_TYPE(x) alignas(x)
  142. # define __WI_ALIGNAS(x) alignas(x)
  143. #else
  144. # define __WI_ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  145. # define __WI_ALIGNAS(x) __attribute__((__aligned__(x)))
  146. #endif
  147. #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
  148. (!defined(__WI_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
  149. # define __WI_LIBCPP_EXPLICIT explicit
  150. #else
  151. # define __WI_LIBCPP_EXPLICIT
  152. #endif
  153. #if __has_feature(cxx_attributes)
  154. # define __WI_LIBCPP_NORETURN [[noreturn]]
  155. #else
  156. # define __WI_LIBCPP_NORETURN __attribute__ ((noreturn))
  157. #endif
  158. #define __WI_LIBCPP_SUPPRESS_NONINIT_ANALYSIS
  159. #define __WI_LIBCPP_SUPPRESS_NOEXCEPT_ANALYSIS
  160. // The __WI_LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
  161. // NODISCARD macros to the correct attribute.
  162. #if __has_cpp_attribute(nodiscard)
  163. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
  164. #elif defined(__WI_LIBCPP_COMPILER_CLANG) && !defined(__WI_LIBCPP_CXX03_LANG)
  165. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
  166. #else
  167. // We can't use GCC's [[gnu::warn_unused_result]] and
  168. // __attribute__((warn_unused_result)), because GCC does not silence them via
  169. // (void) cast.
  170. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE
  171. #endif
  172. #define __WI_HAS_FEATURE_IS_UNION __has_feature(is_union)
  173. #define __WI_HAS_FEATURE_IS_CLASS __has_feature(is_class)
  174. #define __WI_HAS_FEATURE_IS_ENUM __has_feature(is_enum)
  175. #define __WI_HAS_FEATURE_IS_CONVERTIBLE_TO __has_feature(is_convertible_to)
  176. #define __WI_HAS_FEATURE_IS_EMPTY __has_feature(is_empty)
  177. #define __WI_HAS_FEATURE_IS_POLYMORPHIC __has_feature(is_polymorphic)
  178. #define __WI_HAS_FEATURE_HAS_VIRTUAL_DESTRUCTOR __has_feature(has_virtual_destructor)
  179. #define __WI_HAS_FEATURE_REFERENCE_QUALIFIED_FUNCTIONS __has_feature(cxx_reference_qualified_functions)
  180. #define __WI_HAS_FEATURE_IS_CONSTRUCTIBLE __has_feature(is_constructible)
  181. #define __WI_HAS_FEATURE_IS_TRIVIALLY_CONSTRUCTIBLE __has_feature(is_trivially_constructible)
  182. #define __WI_HAS_FEATURE_IS_TRIVIALLY_ASSIGNABLE __has_feature(is_trivially_assignable)
  183. #define __WI_HAS_FEATURE_HAS_TRIVIAL_DESTRUCTOR __has_feature(has_trivial_destructor)
  184. #define __WI_HAS_FEATURE_NOEXCEPT __has_feature(cxx_noexcept)
  185. #define __WI_HAS_FEATURE_IS_POD __has_feature(is_pod)
  186. #define __WI_HAS_FEATURE_IS_STANDARD_LAYOUT __has_feature(is_standard_layout)
  187. #define __WI_HAS_FEATURE_IS_TRIVIALLY_COPYABLE __has_feature(is_trivially_copyable)
  188. #define __WI_HAS_FEATURE_IS_TRIVIAL __has_feature(is_trivial)
  189. #define __WI_HAS_FEATURE_HAS_TRIVIAL_CONSTRUCTOR __has_feature(has_trivial_constructor) || (__WI_GNUC_VER >= 403)
  190. #define __WI_HAS_FEATURE_HAS_NOTHROW_CONSTRUCTOR __has_feature(has_nothrow_constructor) || (__WI_GNUC_VER >= 403)
  191. #define __WI_HAS_FEATURE_HAS_NOTHROW_COPY __has_feature(has_nothrow_copy) || (__WI_GNUC_VER >= 403)
  192. #define __WI_HAS_FEATURE_HAS_NOTHROW_ASSIGN __has_feature(has_nothrow_assign) || (__WI_GNUC_VER >= 403)
  193. #if !(__has_feature(cxx_noexcept))
  194. #define __WI_LIBCPP_HAS_NO_NOEXCEPT
  195. #endif
  196. #if !__is_identifier(__has_unique_object_representations) || __WI_GNUC_VER >= 700
  197. #define __WI_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
  198. #endif
  199. #if !(__has_feature(cxx_variadic_templates))
  200. #define __WI_LIBCPP_HAS_NO_VARIADICS
  201. #endif
  202. #if __has_feature(is_literal) || __WI_GNUC_VER >= 407
  203. #define __WI_LIBCPP_IS_LITERAL(T) __is_literal(T)
  204. #endif
  205. #if __has_feature(underlying_type) || __WI_GNUC_VER >= 407
  206. #define __WI_LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  207. #endif
  208. #if __has_feature(is_final) || __WI_GNUC_VER >= 407
  209. #define __WI_LIBCPP_HAS_IS_FINAL
  210. #endif
  211. #if __has_feature(is_base_of) || defined(__GNUC__) && __WI_GNUC_VER >= 403
  212. #define __WI_LIBCPP_HAS_IS_BASE_OF
  213. #endif
  214. #if __is_identifier(__is_aggregate) && (__WI_GNUC_VER_NEW < 7001)
  215. #define __WI_LIBCPP_HAS_NO_IS_AGGREGATE
  216. #endif
  217. #if !(__has_feature(cxx_rtti)) && !defined(__WI_LIBCPP_NO_RTTI)
  218. #define __WI_LIBCPP_NO_RTTI
  219. #endif
  220. #if !(__has_feature(cxx_variable_templates))
  221. #define __WI_LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  222. #endif
  223. #if !(__has_feature(cxx_relaxed_constexpr))
  224. #define __WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR
  225. #endif
  226. #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
  227. #define __WI_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
  228. #endif
  229. #if __has_attribute(__no_sanitize__) && !defined(__WI_LIBCPP_COMPILER_GCC)
  230. # define __WI_LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
  231. #else
  232. # define __WI_LIBCPP_NO_CFI
  233. #endif
  234. #define __WI_LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  235. #if __has_attribute(internal_linkage)
  236. # define __WI_LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
  237. #else
  238. # define __WI_LIBCPP_INTERNAL_LINKAGE __WI_LIBCPP_ALWAYS_INLINE
  239. #endif
  240. #else
  241. // NOTE: Much of the following assumes a decently recent version of MSVC. Past versions can be supported, but will need
  242. // to be updated to contain the proper _MSC_VER check
  243. #define __WI_ALIGNAS_TYPE(x) alignas(x)
  244. #define __WI_ALIGNAS(x) alignas(x)
  245. #define __alignof__ __alignof
  246. #define __WI_LIBCPP_EXPLICIT explicit
  247. #define __WI_LIBCPP_NORETURN [[noreturn]]
  248. #define __WI_LIBCPP_SUPPRESS_NONINIT_ANALYSIS __pragma(warning(suppress:26495))
  249. #define __WI_LIBCPP_SUPPRESS_NOEXCEPT_ANALYSIS __pragma(warning(suppress:26439))
  250. #if __WI_LIBCPP_STD_VER > 14
  251. #define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
  252. #else
  253. #define __WI_LIBCPP_NODISCARD_ATTRIBUTE _Check_return_
  254. #endif
  255. #define __WI_HAS_FEATURE_IS_UNION 1
  256. #define __WI_HAS_FEATURE_IS_CLASS 1
  257. #define __WI_HAS_FEATURE_IS_ENUM 1
  258. #define __WI_HAS_FEATURE_IS_CONVERTIBLE_TO 1
  259. #define __WI_HAS_FEATURE_IS_EMPTY 1
  260. #define __WI_HAS_FEATURE_IS_POLYMORPHIC 1
  261. #define __WI_HAS_FEATURE_HAS_VIRTUAL_DESTRUCTOR 1
  262. #define __WI_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 1
  263. #define __WI_HAS_FEATURE_REFERENCE_QUALIFIED_FUNCTIONS 1
  264. #define __WI_HAS_FEATURE_IS_CONSTRUCTIBLE 1
  265. #define __WI_HAS_FEATURE_IS_TRIVIALLY_CONSTRUCTIBLE 1
  266. #define __WI_HAS_FEATURE_IS_TRIVIALLY_ASSIGNABLE 1
  267. #define __WI_HAS_FEATURE_HAS_TRIVIAL_DESTRUCTOR 1
  268. #define __WI_HAS_FEATURE_NOEXCEPT 1
  269. #define __WI_HAS_FEATURE_IS_POD 1
  270. #define __WI_HAS_FEATURE_IS_STANDARD_LAYOUT 1
  271. #define __WI_HAS_FEATURE_IS_TRIVIALLY_COPYABLE 1
  272. #define __WI_HAS_FEATURE_IS_TRIVIAL 1
  273. #define __WI_HAS_FEATURE_HAS_TRIVIAL_CONSTRUCTOR 1
  274. #define __WI_HAS_FEATURE_HAS_NOTHROW_CONSTRUCTOR 1
  275. #define __WI_HAS_FEATURE_HAS_NOTHROW_COPY 1
  276. #define __WI_HAS_FEATURE_HAS_NOTHROW_ASSIGN 1
  277. #define __WI_HAS_FEATURE_IS_DESTRUCTIBLE 1
  278. #if !defined(_CPPRTTI) && !defined(__WI_LIBCPP_NO_RTTI)
  279. #define __WI_LIBCPP_NO_RTTI
  280. #endif
  281. #define __WI_LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  282. #define __WI_LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  283. #define __WI_LIBCPP_HAS_IS_FINAL
  284. #define __WI_LIBCPP_HAS_IS_BASE_OF
  285. #if __WI_LIBCPP_STD_VER < 14
  286. #define __WI_LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  287. #endif
  288. #define __WI_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
  289. #define __WI_LIBCPP_NO_CFI
  290. #define __WI_LIBCPP_ALWAYS_INLINE __forceinline
  291. #define __WI_LIBCPP_INTERNAL_LINKAGE
  292. #endif
  293. #ifndef _WIN32
  294. #ifdef __LITTLE_ENDIAN__
  295. # if __LITTLE_ENDIAN__
  296. # define __WI_LIBCPP_LITTLE_ENDIAN
  297. # endif // __LITTLE_ENDIAN__
  298. #endif // __LITTLE_ENDIAN__
  299. #ifdef __BIG_ENDIAN__
  300. # if __BIG_ENDIAN__
  301. # define __WI_LIBCPP_BIG_ENDIAN
  302. # endif // __BIG_ENDIAN__
  303. #endif // __BIG_ENDIAN__
  304. #ifdef __BYTE_ORDER__
  305. # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  306. # define __WI_LIBCPP_LITTLE_ENDIAN
  307. # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  308. # define __WI_LIBCPP_BIG_ENDIAN
  309. # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  310. #endif // __BYTE_ORDER__
  311. #if !defined(__WI_LIBCPP_LITTLE_ENDIAN) && !defined(__WI_LIBCPP_BIG_ENDIAN)
  312. # include <endian.h>
  313. # if __BYTE_ORDER == __LITTLE_ENDIAN
  314. # define __WI_LIBCPP_LITTLE_ENDIAN
  315. # elif __BYTE_ORDER == __BIG_ENDIAN
  316. # define __WI_LIBCPP_BIG_ENDIAN
  317. # else // __BYTE_ORDER == __BIG_ENDIAN
  318. # error unable to determine endian
  319. # endif
  320. #endif // !defined(__WI_LIBCPP_LITTLE_ENDIAN) && !defined(__WI_LIBCPP_BIG_ENDIAN)
  321. #else // _WIN32
  322. #define __WI_LIBCPP_LITTLE_ENDIAN
  323. #endif // _WIN32
  324. #ifdef __WI_LIBCPP_HAS_NO_CONSTEXPR
  325. # define __WI_LIBCPP_CONSTEXPR
  326. #else
  327. # define __WI_LIBCPP_CONSTEXPR constexpr
  328. #endif
  329. #if __WI_LIBCPP_STD_VER > 11 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  330. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  331. #else
  332. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  333. #endif
  334. #if __WI_LIBCPP_STD_VER > 14 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  335. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  336. #else
  337. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX14
  338. #endif
  339. #if __WI_LIBCPP_STD_VER > 17 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  340. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
  341. #else
  342. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX17
  343. #endif
  344. #if !defined(__WI_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
  345. (__WI_LIBCPP_STD_VER > 17 || defined(__WI_LIBCPP_ENABLE_NODISCARD))
  346. # define __WI_LIBCPP_NODISCARD_AFTER_CXX17 __WI_LIBCPP_NODISCARD_ATTRIBUTE
  347. #else
  348. # define __WI_LIBCPP_NODISCARD_AFTER_CXX17
  349. #endif
  350. #if __WI_LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
  351. # define __WI_LIBCPP_INLINE_VAR inline
  352. #else
  353. # define __WI_LIBCPP_INLINE_VAR
  354. #endif
  355. #ifdef __WI_LIBCPP_CXX03_LANG
  356. #define __WI_LIBCPP_HAS_NO_UNICODE_CHARS
  357. #define __WI_LIBCPP_HAS_NO_RVALUE_REFERENCES
  358. #endif
  359. #ifndef __SIZEOF_INT128__
  360. #define __WI_LIBCPP_HAS_NO_INT128
  361. #endif
  362. #if !__WI_HAS_FEATURE_NOEXCEPT && !defined(__WI_LIBCPP_HAS_NO_NOEXCEPT)
  363. #define __WI_LIBCPP_HAS_NO_NOEXCEPT
  364. #endif
  365. #ifndef __WI_LIBCPP_HAS_NO_NOEXCEPT
  366. # define WI_NOEXCEPT noexcept
  367. # define __WI_NOEXCEPT_(x) noexcept(x)
  368. #else
  369. # define WI_NOEXCEPT throw()
  370. # define __WI_NOEXCEPT_(x)
  371. #endif
  372. #if defined(__WI_LIBCPP_OBJECT_FORMAT_COFF)
  373. #define __WI_LIBCPP_HIDDEN
  374. #define __WI_LIBCPP_TEMPLATE_VIS
  375. #endif // defined(__WI_LIBCPP_OBJECT_FORMAT_COFF)
  376. #ifndef __WI_LIBCPP_HIDDEN
  377. # if !defined(__WI_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  378. # define __WI_LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
  379. # else
  380. # define __WI_LIBCPP_HIDDEN
  381. # endif
  382. #endif
  383. #ifndef __WI_LIBCPP_TEMPLATE_VIS
  384. # if !defined(__WI_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !defined(__WI_LIBCPP_COMPILER_MSVC)
  385. # if __has_attribute(__type_visibility__)
  386. # define __WI_LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
  387. # else
  388. # define __WI_LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
  389. # endif
  390. # else
  391. # define __WI_LIBCPP_TEMPLATE_VIS
  392. # endif
  393. #endif
  394. #define __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_HIDDEN __WI_LIBCPP_INTERNAL_LINKAGE
  395. namespace wistd // ("Windows Implementation" std)
  396. {
  397. using nullptr_t = decltype(__nullptr);
  398. template <class _T1, class _T2 = _T1>
  399. struct __less
  400. {
  401. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  402. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  403. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  404. bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
  405. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  406. bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
  407. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  408. bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
  409. };
  410. template <class _T1>
  411. struct __less<_T1, _T1>
  412. {
  413. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  414. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  415. };
  416. template <class _T1>
  417. struct __less<const _T1, _T1>
  418. {
  419. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  420. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  421. };
  422. template <class _T1>
  423. struct __less<_T1, const _T1>
  424. {
  425. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  426. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  427. };
  428. // These are added to wistd to enable use of min/max without having to use the windows.h min/max
  429. // macros that some clients might not have access to. Note: the STL versions of these have debug
  430. // checking for the less than operator and support for iterators that these implementations lack.
  431. // Use the STL versions when you require use of those features.
  432. // min
  433. template <class _Tp, class _Compare>
  434. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  435. const _Tp&
  436. (min)(const _Tp& __a, const _Tp& __b, _Compare __comp)
  437. {
  438. return __comp(__b, __a) ? __b : __a;
  439. }
  440. template <class _Tp>
  441. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  442. const _Tp&
  443. (min)(const _Tp& __a, const _Tp& __b)
  444. {
  445. return (min)(__a, __b, __less<_Tp>());
  446. }
  447. // max
  448. template <class _Tp, class _Compare>
  449. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  450. const _Tp&
  451. (max)(const _Tp& __a, const _Tp& __b, _Compare __comp)
  452. {
  453. return __comp(__a, __b) ? __b : __a;
  454. }
  455. template <class _Tp>
  456. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  457. const _Tp&
  458. (max)(const _Tp& __a, const _Tp& __b)
  459. {
  460. return (max)(__a, __b, __less<_Tp>());
  461. }
  462. template <class _Arg, class _Result>
  463. struct __WI_LIBCPP_TEMPLATE_VIS unary_function
  464. {
  465. using argument_type = _Arg;
  466. using result_type = _Result;
  467. };
  468. template <class _Arg1, class _Arg2, class _Result>
  469. struct __WI_LIBCPP_TEMPLATE_VIS binary_function
  470. {
  471. using first_argument_type = _Arg1;
  472. using second_argument_type = _Arg2;
  473. using result_type = _Result;
  474. };
  475. }
  476. /// @endcond
  477. #endif // _WISTD_CONFIG_H_