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