You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

549 lines
19KB

  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 <stddef.h> // 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. // NOTE: MSVC, which is what we primarily target, is severly underrepresented in libc++ and checks such as
  98. // __has_feature(...) are always false for MSVC, even when the feature being tested _is_ present in MSVC. Therefore, we
  99. // instead modify all checks to be __WI_HAS_FEATURE_IS_UNION, etc., which provides the correct value for MSVC and falls
  100. // back to the __has_feature(...), etc. value otherwise. We intentionally leave '__has_feature', etc. undefined for MSVC
  101. // so that we don't accidentally use the incorrect behavior
  102. #ifndef __WI_LIBCPP_COMPILER_MSVC
  103. #ifndef __has_feature
  104. #define __has_feature(__x) 0
  105. #endif
  106. // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
  107. // the compiler and '1' otherwise.
  108. #ifndef __is_identifier
  109. #define __is_identifier(__x) 1
  110. #endif
  111. #ifndef __has_cpp_attribute
  112. #define __has_cpp_attribute(__x) 0
  113. #endif
  114. #ifndef __has_attribute
  115. #define __has_attribute(__x) 0
  116. #endif
  117. #ifndef __has_builtin
  118. #define __has_builtin(__x) 0
  119. #endif
  120. #if __has_feature(cxx_alignas)
  121. # define __WI_ALIGNAS_TYPE(x) alignas(x)
  122. # define __WI_ALIGNAS(x) alignas(x)
  123. #else
  124. # define __WI_ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  125. # define __WI_ALIGNAS(x) __attribute__((__aligned__(x)))
  126. #endif
  127. #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
  128. (!defined(__WI_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
  129. # define __WI_LIBCPP_EXPLICIT explicit
  130. #else
  131. # define __WI_LIBCPP_EXPLICIT
  132. #endif
  133. #if __has_feature(cxx_attributes)
  134. # define __WI_LIBCPP_NORETURN [[noreturn]]
  135. #else
  136. # define __WI_LIBCPP_NORETURN __attribute__ ((noreturn))
  137. #endif
  138. #define __WI_LIBCPP_SUPPRESS_NONINIT_ANALYSIS
  139. #define __WI_LIBCPP_SUPPRESS_NOEXCEPT_ANALYSIS
  140. // The __WI_LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
  141. // NODISCARD macros to the correct attribute.
  142. #if __has_cpp_attribute(nodiscard)
  143. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
  144. #elif defined(__WI_LIBCPP_COMPILER_CLANG) && !defined(__WI_LIBCPP_CXX03_LANG)
  145. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
  146. #else
  147. // We can't use GCC's [[gnu::warn_unused_result]] and
  148. // __attribute__((warn_unused_result)), because GCC does not silence them via
  149. // (void) cast.
  150. # define __WI_LIBCPP_NODISCARD_ATTRIBUTE
  151. #endif
  152. #define __WI_HAS_FEATURE_IS_UNION __has_feature(is_union)
  153. #define __WI_HAS_FEATURE_IS_CLASS __has_feature(is_class)
  154. #define __WI_HAS_FEATURE_IS_ENUM __has_feature(is_enum)
  155. #define __WI_HAS_FEATURE_IS_CONVERTIBLE_TO __has_feature(is_convertible_to)
  156. #define __WI_HAS_FEATURE_IS_EMPTY __has_feature(is_empty)
  157. #define __WI_HAS_FEATURE_IS_POLYMORPHIC __has_feature(is_polymorphic)
  158. #define __WI_HAS_FEATURE_HAS_VIRTUAL_DESTRUCTOR __has_feature(has_virtual_destructor)
  159. #define __WI_HAS_FEATURE_REFERENCE_QUALIFIED_FUNCTIONS __has_feature(cxx_reference_qualified_functions)
  160. #define __WI_HAS_FEATURE_IS_CONSTRUCTIBLE __has_feature(is_constructible)
  161. #define __WI_HAS_FEATURE_IS_TRIVIALLY_CONSTRUCTIBLE __has_feature(is_trivially_constructible)
  162. #define __WI_HAS_FEATURE_IS_TRIVIALLY_ASSIGNABLE __has_feature(is_trivially_assignable)
  163. #define __WI_HAS_FEATURE_HAS_TRIVIAL_DESTRUCTOR __has_feature(has_trivial_destructor)
  164. #define __WI_HAS_FEATURE_NOEXCEPT __has_feature(cxx_noexcept)
  165. #define __WI_HAS_FEATURE_IS_POD __has_feature(is_pod)
  166. #define __WI_HAS_FEATURE_IS_STANDARD_LAYOUT __has_feature(is_standard_layout)
  167. #define __WI_HAS_FEATURE_IS_TRIVIALLY_COPYABLE __has_feature(is_trivially_copyable)
  168. #define __WI_HAS_FEATURE_IS_TRIVIAL __has_feature(is_trivial)
  169. #define __WI_HAS_FEATURE_HAS_TRIVIAL_CONSTRUCTOR __has_feature(has_trivial_constructor) || (__WI_GNUC_VER >= 403)
  170. #define __WI_HAS_FEATURE_HAS_NOTHROW_CONSTRUCTOR __has_feature(has_nothrow_constructor) || (__WI_GNUC_VER >= 403)
  171. #define __WI_HAS_FEATURE_HAS_NOTHROW_COPY __has_feature(has_nothrow_copy) || (__WI_GNUC_VER >= 403)
  172. #define __WI_HAS_FEATURE_HAS_NOTHROW_ASSIGN __has_feature(has_nothrow_assign) || (__WI_GNUC_VER >= 403)
  173. #if !(__has_feature(cxx_noexcept))
  174. #define __WI_LIBCPP_HAS_NO_NOEXCEPT
  175. #endif
  176. #if !__is_identifier(__has_unique_object_representations) || __WI_GNUC_VER >= 700
  177. #define __WI_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
  178. #endif
  179. #if !(__has_feature(cxx_variadic_templates))
  180. #define __WI_LIBCPP_HAS_NO_VARIADICS
  181. #endif
  182. #if __has_feature(is_literal) || __WI_GNUC_VER >= 407
  183. #define __WI_LIBCPP_IS_LITERAL(T) __is_literal(T)
  184. #endif
  185. #if __has_feature(underlying_type) || __WI_GNUC_VER >= 407
  186. #define __WI_LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  187. #endif
  188. #if __has_feature(is_final) || __WI_GNUC_VER >= 407
  189. #define __WI_LIBCPP_HAS_IS_FINAL
  190. #endif
  191. #if __has_feature(is_base_of) || defined(__GNUC__) && __WI_GNUC_VER >= 403
  192. #define __WI_LIBCPP_HAS_IS_BASE_OF
  193. #endif
  194. #if __is_identifier(__is_aggregate) && (__WI_GNUC_VER_NEW < 7001)
  195. #define __WI_LIBCPP_HAS_NO_IS_AGGREGATE
  196. #endif
  197. #if !(__has_feature(cxx_rtti)) && !defined(__WI_LIBCPP_NO_RTTI)
  198. #define __WI_LIBCPP_NO_RTTI
  199. #endif
  200. #if !(__has_feature(cxx_variable_templates))
  201. #define __WI_LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  202. #endif
  203. #if !(__has_feature(cxx_relaxed_constexpr))
  204. #define __WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR
  205. #endif
  206. #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
  207. #define __WI_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
  208. #endif
  209. #if __has_attribute(__no_sanitize__) && !defined(__WI_LIBCPP_COMPILER_GCC)
  210. # define __WI_LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
  211. #else
  212. # define __WI_LIBCPP_NO_CFI
  213. #endif
  214. #define __WI_LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  215. #if __has_attribute(internal_linkage)
  216. # define __WI_LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
  217. #else
  218. # define __WI_LIBCPP_INTERNAL_LINKAGE __WI_LIBCPP_ALWAYS_INLINE
  219. #endif
  220. #else
  221. // NOTE: Much of the following assumes a decently recent version of MSVC. Past versions can be supported, but will need
  222. // to be updated to contain the proper _MSC_VER check
  223. #define __WI_ALIGNAS_TYPE(x) alignas(x)
  224. #define __WI_ALIGNAS(x) alignas(x)
  225. #define __alignof__ __alignof
  226. #define __WI_LIBCPP_EXPLICIT explicit
  227. #define __WI_LIBCPP_NORETURN [[noreturn]]
  228. #define __WI_LIBCPP_SUPPRESS_NONINIT_ANALYSIS __pragma(warning(suppress:26495))
  229. #define __WI_LIBCPP_SUPPRESS_NOEXCEPT_ANALYSIS __pragma(warning(suppress:26439))
  230. #if __WI_LIBCPP_STD_VER > 14
  231. #define __WI_LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
  232. #else
  233. #define __WI_LIBCPP_NODISCARD_ATTRIBUTE _Check_return_
  234. #endif
  235. #define __WI_HAS_FEATURE_IS_UNION 1
  236. #define __WI_HAS_FEATURE_IS_CLASS 1
  237. #define __WI_HAS_FEATURE_IS_ENUM 1
  238. #define __WI_HAS_FEATURE_IS_CONVERTIBLE_TO 1
  239. #define __WI_HAS_FEATURE_IS_EMPTY 1
  240. #define __WI_HAS_FEATURE_IS_POLYMORPHIC 1
  241. #define __WI_HAS_FEATURE_HAS_VIRTUAL_DESTRUCTOR 1
  242. #define __WI_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 1
  243. #define __WI_HAS_FEATURE_REFERENCE_QUALIFIED_FUNCTIONS 1
  244. #define __WI_HAS_FEATURE_IS_CONSTRUCTIBLE 1
  245. #define __WI_HAS_FEATURE_IS_TRIVIALLY_CONSTRUCTIBLE 1
  246. #define __WI_HAS_FEATURE_IS_TRIVIALLY_ASSIGNABLE 1
  247. #define __WI_HAS_FEATURE_HAS_TRIVIAL_DESTRUCTOR 1
  248. #define __WI_HAS_FEATURE_NOEXCEPT 1
  249. #define __WI_HAS_FEATURE_IS_POD 1
  250. #define __WI_HAS_FEATURE_IS_STANDARD_LAYOUT 1
  251. #define __WI_HAS_FEATURE_IS_TRIVIALLY_COPYABLE 1
  252. #define __WI_HAS_FEATURE_IS_TRIVIAL 1
  253. #define __WI_HAS_FEATURE_HAS_TRIVIAL_CONSTRUCTOR 1
  254. #define __WI_HAS_FEATURE_HAS_NOTHROW_CONSTRUCTOR 1
  255. #define __WI_HAS_FEATURE_HAS_NOTHROW_COPY 1
  256. #define __WI_HAS_FEATURE_HAS_NOTHROW_ASSIGN 1
  257. #define __WI_HAS_FEATURE_IS_DESTRUCTIBLE 1
  258. #if !defined(_CPPRTTI) && !defined(__WI_LIBCPP_NO_RTTI)
  259. #define __WI_LIBCPP_NO_RTTI
  260. #endif
  261. #define __WI_LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  262. #define __WI_LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  263. #define __WI_LIBCPP_HAS_IS_FINAL
  264. #define __WI_LIBCPP_HAS_IS_BASE_OF
  265. #if __WI_LIBCPP_STD_VER < 14
  266. #define __WI_LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  267. #endif
  268. #define __WI_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
  269. #define __WI_LIBCPP_NO_CFI
  270. #define __WI_LIBCPP_ALWAYS_INLINE __forceinline
  271. #define __WI_LIBCPP_INTERNAL_LINKAGE
  272. #endif
  273. #ifndef _WIN32
  274. #ifdef __LITTLE_ENDIAN__
  275. # if __LITTLE_ENDIAN__
  276. # define __WI_LIBCPP_LITTLE_ENDIAN
  277. # endif // __LITTLE_ENDIAN__
  278. #endif // __LITTLE_ENDIAN__
  279. #ifdef __BIG_ENDIAN__
  280. # if __BIG_ENDIAN__
  281. # define __WI_LIBCPP_BIG_ENDIAN
  282. # endif // __BIG_ENDIAN__
  283. #endif // __BIG_ENDIAN__
  284. #ifdef __BYTE_ORDER__
  285. # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  286. # define __WI_LIBCPP_LITTLE_ENDIAN
  287. # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  288. # define __WI_LIBCPP_BIG_ENDIAN
  289. # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  290. #endif // __BYTE_ORDER__
  291. #if !defined(__WI_LIBCPP_LITTLE_ENDIAN) && !defined(__WI_LIBCPP_BIG_ENDIAN)
  292. # include <endian.h>
  293. # if __BYTE_ORDER == __LITTLE_ENDIAN
  294. # define __WI_LIBCPP_LITTLE_ENDIAN
  295. # elif __BYTE_ORDER == __BIG_ENDIAN
  296. # define __WI_LIBCPP_BIG_ENDIAN
  297. # else // __BYTE_ORDER == __BIG_ENDIAN
  298. # error unable to determine endian
  299. # endif
  300. #endif // !defined(__WI_LIBCPP_LITTLE_ENDIAN) && !defined(__WI_LIBCPP_BIG_ENDIAN)
  301. #else // _WIN32
  302. #define __WI_LIBCPP_LITTLE_ENDIAN
  303. #endif // _WIN32
  304. #ifdef __WI_LIBCPP_HAS_NO_CONSTEXPR
  305. # define __WI_LIBCPP_CONSTEXPR
  306. #else
  307. # define __WI_LIBCPP_CONSTEXPR constexpr
  308. #endif
  309. #if __WI_LIBCPP_STD_VER > 11 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  310. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  311. #else
  312. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  313. #endif
  314. #if __WI_LIBCPP_STD_VER > 14 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  315. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  316. #else
  317. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX14
  318. #endif
  319. #if __WI_LIBCPP_STD_VER > 17 && !defined(__WI_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  320. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
  321. #else
  322. # define __WI_LIBCPP_CONSTEXPR_AFTER_CXX17
  323. #endif
  324. #if !defined(__WI_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
  325. (__WI_LIBCPP_STD_VER > 17 || defined(__WI_LIBCPP_ENABLE_NODISCARD))
  326. # define __WI_LIBCPP_NODISCARD_AFTER_CXX17 __WI_LIBCPP_NODISCARD_ATTRIBUTE
  327. #else
  328. # define __WI_LIBCPP_NODISCARD_AFTER_CXX17
  329. #endif
  330. #if __WI_LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
  331. # define __WI_LIBCPP_INLINE_VAR inline
  332. #else
  333. # define __WI_LIBCPP_INLINE_VAR
  334. #endif
  335. #ifdef __WI_LIBCPP_CXX03_LANG
  336. #define __WI_LIBCPP_HAS_NO_UNICODE_CHARS
  337. #define __WI_LIBCPP_HAS_NO_RVALUE_REFERENCES
  338. #endif
  339. #ifndef __SIZEOF_INT128__
  340. #define __WI_LIBCPP_HAS_NO_INT128
  341. #endif
  342. #if !__WI_HAS_FEATURE_NOEXCEPT && !defined(__WI_LIBCPP_HAS_NO_NOEXCEPT)
  343. #define __WI_LIBCPP_HAS_NO_NOEXCEPT
  344. #endif
  345. #ifndef __WI_LIBCPP_HAS_NO_NOEXCEPT
  346. # define WI_NOEXCEPT noexcept
  347. # define __WI_NOEXCEPT_(x) noexcept(x)
  348. #else
  349. # define WI_NOEXCEPT throw()
  350. # define __WI_NOEXCEPT_(x)
  351. #endif
  352. #if defined(__WI_LIBCPP_OBJECT_FORMAT_COFF)
  353. #define __WI_LIBCPP_HIDDEN
  354. #define __WI_LIBCPP_TEMPLATE_VIS
  355. #endif // defined(__WI_LIBCPP_OBJECT_FORMAT_COFF)
  356. #ifndef __WI_LIBCPP_HIDDEN
  357. # if !defined(__WI_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  358. # define __WI_LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
  359. # else
  360. # define __WI_LIBCPP_HIDDEN
  361. # endif
  362. #endif
  363. #ifndef __WI_LIBCPP_TEMPLATE_VIS
  364. # if !defined(__WI_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !defined(__WI_LIBCPP_COMPILER_MSVC)
  365. # if __has_attribute(__type_visibility__)
  366. # define __WI_LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
  367. # else
  368. # define __WI_LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
  369. # endif
  370. # else
  371. # define __WI_LIBCPP_TEMPLATE_VIS
  372. # endif
  373. #endif
  374. #define __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_HIDDEN __WI_LIBCPP_INTERNAL_LINKAGE
  375. namespace wistd // ("Windows Implementation" std)
  376. {
  377. typedef decltype(__nullptr) nullptr_t;
  378. template <class _T1, class _T2 = _T1>
  379. struct __less
  380. {
  381. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  382. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  383. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  384. bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
  385. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  386. bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
  387. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  388. bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
  389. };
  390. template <class _T1>
  391. struct __less<_T1, _T1>
  392. {
  393. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  394. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  395. };
  396. template <class _T1>
  397. struct __less<const _T1, _T1>
  398. {
  399. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  400. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  401. };
  402. template <class _T1>
  403. struct __less<_T1, const _T1>
  404. {
  405. __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  406. bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
  407. };
  408. // These are added to wistd to enable use of min/max without having to use the windows.h min/max
  409. // macros that some clients might not have access to. Note: the STL versions of these have debug
  410. // checking for the less than operator and support for iterators that these implementations lack.
  411. // Use the STL versions when you require use of those features.
  412. // min
  413. template <class _Tp, class _Compare>
  414. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  415. const _Tp&
  416. (min)(const _Tp& __a, const _Tp& __b, _Compare __comp)
  417. {
  418. return __comp(__b, __a) ? __b : __a;
  419. }
  420. template <class _Tp>
  421. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  422. const _Tp&
  423. (min)(const _Tp& __a, const _Tp& __b)
  424. {
  425. return (min)(__a, __b, __less<_Tp>());
  426. }
  427. // max
  428. template <class _Tp, class _Compare>
  429. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  430. const _Tp&
  431. (max)(const _Tp& __a, const _Tp& __b, _Compare __comp)
  432. {
  433. return __comp(__a, __b) ? __b : __a;
  434. }
  435. template <class _Tp>
  436. inline __WI_LIBCPP_INLINE_VISIBILITY __WI_LIBCPP_CONSTEXPR_AFTER_CXX11
  437. const _Tp&
  438. (max)(const _Tp& __a, const _Tp& __b)
  439. {
  440. return (max)(__a, __b, __less<_Tp>());
  441. }
  442. template <class _Arg, class _Result>
  443. struct __WI_LIBCPP_TEMPLATE_VIS unary_function
  444. {
  445. typedef _Arg argument_type;
  446. typedef _Result result_type;
  447. };
  448. template <class _Arg1, class _Arg2, class _Result>
  449. struct __WI_LIBCPP_TEMPLATE_VIS binary_function
  450. {
  451. typedef _Arg1 first_argument_type;
  452. typedef _Arg2 second_argument_type;
  453. typedef _Result result_type;
  454. };
  455. }
  456. /// @endcond
  457. #endif _WISTD_CONFIG_H_