From 0bad519c0c3cfa8cc7947cc862bc42b69add3470 Mon Sep 17 00:00:00 2001 From: dim Date: Fri, 13 Feb 2015 22:05:54 +0000 Subject: [PATCH] Synchronize the default C++ stack in stable/10 with head, by merging almost all recent changes to libc++ and libcxxrt. MFC r256642: Since C++ typeinfo objects are currently not guaranteed to be merged at runtime by the dynamic linker, check for their equality in libcxxrt by not only comparing the typeinfo's name pointers, but also comparing the full names, if necessary. (This is similar to what GNU libstdc++ does in its default configuration.) The 'deep' check can be turned off again by defining LIBCXXRT_MERGED_TYPEINFO, and recompiling libcxxrt. Reviewed by: theraven MFC r270522 (by rdivacky): The standard we compile libc++ with is called c++11 not c++0x. MFC r273066 (by bapt): Import patch from libc++ r197313 which allows using libc++ headers with gcc Differential Revision: https://reviews.freebsd.org/D942 Reviewed by: imp MFC r273381 (by bapt): Add support for __cxa_throw_bad_array_new_length in libcxxrt It is required for use with newer g++49 Differential Revision: https://reviews.freebsd.org/D982 Reviewed by: theraven Approved by: theraven MFC r273382 (by bapt): Fix build by marking the new functions as weak This is a temporary fix MFC r273407 (by bapt): When using an external gcc 4.8+ and not building libstdc++ then create in the objectdir a fake libstdc++.so and libstdc++.a which is a symlink on libc++ that allow g++ to satisfy its links dependencies in the least hackish way. Please note that this hacky libstds++ never get installed on the final system Reviewed by: imp MFC r273434 (by bapt): Do not define bad_array_new_length::bad_array_new_length in libc++ anymore when used in combinaison with libcxxrt since it is now defined there already. This fixes building world MFC r276417: Import libcxxrt master 00bc29eb6513624824a6d7db2ebc768a4216a604. Interesting fixes: 76584a0 Reorganize code to use only 32bit atomic ops for 32bit platforms 30d2ae5 Implement __cxa_throw_bad_array_new_length Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D1390 MFC r277217: Import libc++ trunk r224926. This fixes a number of bugs, completes C++14 support[1], adds more C++1z features[2], and fixes the following LWG issues[3]: 1450: Contradiction in regex_constants 2003: String exception inconsistency in erase. 2075: Progress guarantees, lock-free property, and scheduling assumptions 2104: unique_lock move-assignment should not be noexcept 2112: User-defined classes that cannot be derived from 2132: std::function ambiguity 2135: Unclear requirement for exceptions thrown in condition_variable::wait() 2142: packaged_task::operator() synchronization too broad? 2182: Container::[const_]reference types are misleadingly specified 2186: Incomplete action on async/launch::deferred 2188: Reverse iterator does not fully support targets that overload operator& 2193: Default constructors for standard library containers are explicit 2205: Problematic postconditions of regex_match and regex_search 2213: Return value of std::regex_replace 2240: Probable misuse of term "function scope" in [thread.condition] 2252: Strong guarantee on vector::push_back() still broken with C++11? 2257: Simplify container requirements with the new algorithms 2258: a.erase(q1, q2) unable to directly return q2 2263: Comparing iterators and allocator pointers with different const-character 2268: Setting a default argument in the declaration of a member function assign of std::basic_string 2271: regex_traits::lookup_classname specification unclear 2272: quoted should use char_traits::eq for character comparison 2278: User-defined literals for Standard Library types 2280: begin / end for arrays should be constexpr and noexcept 2285: make_reverse_iterator 2288: Inconsistent requirements for shared mutexes 2291: std::hash is vulnerable to collision DoS attack 2293: Wrong facet used by num_put::do_put 2299: Effects of inaccessible key_compare::is_transparent type are not clear 2301: Why is std::tie not constexpr? 2304: Complexity of count in unordered associative containers 2306: match_results::reference should be value_type&, not const value_type& 2308: Clarify container destructor requirements w.r.t. std::array 2313: tuple_size should always derive from integral_constant 2314: apply() should return decltype(auto) and use decay_t before tuple_size 2315: weak_ptr should be movable 2316: weak_ptr::lock() should be atomic 2317: The type property queries should be UnaryTypeTraits returning size_t 2320: select_on_container_copy_construction() takes allocators, not containers 2322: Associative(initializer_list, stuff) constructors are underspecified 2323: vector::resize(n, t)'s specification should be simplified 2324: Insert iterator constructors should use addressof() 2329: regex_match()/regex_search() with match_results should forbid temporary strings 2330: regex("meow", regex::icase) is technically forbidden but should be permitted 2332: regex_iterator/regex_token_iterator should forbid temporary regexes 2339: Wording issue in nth_element 2341: Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir) 2344: quoted()'s interaction with padding is unclear 2346: integral_constant's member functions should be marked noexcept 2350: min, max, and minmax should be constexpr 2356: Stability of erasure in unordered associative containers 2357: Remaining "Assignable" requirement 2359: How does regex_constants::nosubs affect basic_regex::mark_count()? 2360: reverse_iterator::operator*() is unimplementable [1] http://libcxx.llvm.org/cxx1y_status.html [2] http://libcxx.llvm.org/cxx1z_status.html [3] http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html Exp-run: antoine MFC r277944: Partially revert r273382, to reduce diffs against upstream. This was a temporary fix to solve a conflict with an older version of libc++, and it is no longer relevant. MFC r278010: Revert r256642, not only to reduce diffs against upstream libcxxrt, but also because it is the wrong approach: comparing typeinfo names deeply causes trouble if two loaded DSOs use independent types of the same name. In addition, this particular change was never merged to FreeBSD 10.x and 9.x, so let's get rid of it before it ends up in an 11.x release. Discussed with: theraven, joerg@netbsd MFC r278016: Import libcxxrt master 1cb607e89f6135bbc10f3d3b6fba1f983e258dcc. Interesting fixes: 1cb607e Correct gcc version check for __cxa_begin_catch() declaration with or without throw() git-svn-id: svn://svn.freebsd.org/base/stable/10@278724 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/libc++/CREDITS.TXT | 4 + contrib/libc++/LICENSE.TXT | 4 +- contrib/libc++/include/__bit_reference | 6 +- contrib/libc++/include/__config | 162 +++- contrib/libc++/include/__debug | 6 +- contrib/libc++/include/__functional_03 | 21 +- contrib/libc++/include/__functional_base | 6 +- contrib/libc++/include/__functional_base_03 | 12 +- contrib/libc++/include/__hash_table | 6 +- contrib/libc++/include/__locale | 26 +- contrib/libc++/include/__mutex_base | 26 +- contrib/libc++/include/__refstring | 139 +++ contrib/libc++/include/__sso_allocator | 4 +- contrib/libc++/include/__tree | 2 +- contrib/libc++/include/__tuple | 98 ++- contrib/libc++/include/algorithm | 354 +++++--- contrib/libc++/include/atomic | 259 +++++- contrib/libc++/include/bitset | 4 +- contrib/libc++/include/chrono | 4 + contrib/libc++/include/cmath | 515 ++++++----- contrib/libc++/include/condition_variable | 4 + contrib/libc++/include/cstddef | 11 +- contrib/libc++/include/deque | 8 +- contrib/libc++/include/experimental/__config | 24 + contrib/libc++/include/experimental/dynarray | 30 +- contrib/libc++/include/experimental/optional | 447 +++++++--- .../libc++/include/experimental/string_view | 815 ++++++++++++++++++ .../libc++/include/experimental/type_traits | 423 +++++++++ contrib/libc++/include/experimental/utility | 44 + contrib/libc++/include/ext/__hash | 93 +- contrib/libc++/include/ext/hash_map | 4 +- contrib/libc++/include/forward_list | 34 +- contrib/libc++/include/functional | 33 +- contrib/libc++/include/future | 78 +- contrib/libc++/include/iomanip | 11 +- contrib/libc++/include/ios | 4 +- contrib/libc++/include/istream | 18 +- contrib/libc++/include/iterator | 89 +- contrib/libc++/include/limits | 6 +- contrib/libc++/include/list | 92 +- contrib/libc++/include/locale | 50 +- contrib/libc++/include/map | 34 +- contrib/libc++/include/memory | 314 +++---- contrib/libc++/include/module.modulemap | 472 ++++++++++ contrib/libc++/include/mutex | 7 +- contrib/libc++/include/new | 20 + contrib/libc++/include/numeric | 14 +- contrib/libc++/include/ostream | 260 +----- contrib/libc++/include/random | 9 +- contrib/libc++/include/regex | 184 +++- contrib/libc++/include/set | 36 +- contrib/libc++/include/shared_mutex | 50 +- contrib/libc++/include/sstream | 5 + contrib/libc++/include/stdexcept | 12 +- contrib/libc++/include/string | 595 +++++++------ contrib/libc++/include/thread | 7 + contrib/libc++/include/tuple | 113 ++- contrib/libc++/include/type_traits | 601 ++++++++++--- contrib/libc++/include/typeinfo | 46 +- contrib/libc++/include/unordered_map | 2 + contrib/libc++/include/unordered_set | 2 + contrib/libc++/include/utility | 36 +- contrib/libc++/include/valarray | 39 +- contrib/libc++/include/vector | 115 ++- contrib/libc++/src/algorithm.cpp | 9 +- contrib/libc++/src/chrono.cpp | 9 +- contrib/libc++/src/condition_variable.cpp | 10 +- contrib/libc++/src/debug.cpp | 40 + contrib/libc++/src/exception.cpp | 2 +- contrib/libc++/src/future.cpp | 15 + contrib/libc++/src/hash.cpp | 2 +- contrib/libc++/src/ios.cpp | 88 +- contrib/libc++/src/locale.cpp | 52 +- contrib/libc++/src/memory.cpp | 10 +- contrib/libc++/src/mutex.cpp | 27 + contrib/libc++/src/new.cpp | 20 +- contrib/libc++/src/optional.cpp | 5 +- contrib/libc++/src/random.cpp | 68 +- contrib/libc++/src/regex.cpp | 14 +- contrib/libc++/src/shared_mutex.cpp | 19 +- contrib/libc++/src/stdexcept.cpp | 122 +-- contrib/libc++/src/string.cpp | 6 +- contrib/libc++/src/strstream.cpp | 14 +- contrib/libc++/src/system_error.cpp | 21 +- contrib/libc++/src/thread.cpp | 19 +- contrib/libc++/src/valarray.cpp | 2 - contrib/libcxxrt/atomic.h | 4 +- contrib/libcxxrt/auxhelper.cc | 5 + contrib/libcxxrt/cxxabi.h | 2 +- contrib/libcxxrt/dwarf_eh.h | 60 +- contrib/libcxxrt/dynamic_cast.cc | 10 +- contrib/libcxxrt/exception.cc | 137 +-- contrib/libcxxrt/guard.cc | 105 ++- contrib/libcxxrt/stdexcept.cc | 13 + contrib/libcxxrt/stdexcept.h | 9 + contrib/libcxxrt/typeinfo.cc | 2 +- contrib/libcxxrt/unwind-arm.h | 2 +- contrib/libcxxrt/unwind.h | 2 +- lib/libc++/Makefile | 23 +- lib/libcxxrt/Version.map | 9 + 100 files changed, 5766 insertions(+), 2140 deletions(-) create mode 100644 contrib/libc++/include/__refstring create mode 100644 contrib/libc++/include/experimental/__config create mode 100644 contrib/libc++/include/experimental/string_view create mode 100644 contrib/libc++/include/experimental/type_traits create mode 100644 contrib/libc++/include/experimental/utility create mode 100644 contrib/libc++/include/module.modulemap diff --git a/contrib/libc++/CREDITS.TXT b/contrib/libc++/CREDITS.TXT index 368b526fc..7a28adae0 100644 --- a/contrib/libc++/CREDITS.TXT +++ b/contrib/libc++/CREDITS.TXT @@ -33,6 +33,10 @@ E: mclow.lists@gmail.com E: marshall@idio.com D: C++14 support, patches and bug fixes. +N: Eric Fiselier +E: eric@efcs.ca +D: LFTS support, patches and bug fixes. + N: Bill Fisher E: william.w.fisher@gmail.com D: Regex bug fixes. diff --git a/contrib/libc++/LICENSE.TXT b/contrib/libc++/LICENSE.TXT index 5ed8ec224..41ca5d19c 100644 --- a/contrib/libc++/LICENSE.TXT +++ b/contrib/libc++/LICENSE.TXT @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT All rights reserved. @@ -55,7 +55,7 @@ SOFTWARE. ============================================================================== -Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/contrib/libc++/include/__bit_reference b/contrib/libc++/include/__bit_reference index 37b792371..4938f4460 100644 --- a/contrib/libc++/include/__bit_reference +++ b/contrib/libc++/include/__bit_reference @@ -174,7 +174,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type if (__b) return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); if (__n == __dn) - return _It(__first.__seg_, __first.__ctz_ + __n); + return __first + __n; __n -= __dn; ++__first.__seg_; } @@ -210,7 +210,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type if (__b) return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); if (__n == __dn) - return _It(__first.__seg_, __first.__ctz_ + __n); + return __first + __n; __n -= __dn; ++__first.__seg_; } @@ -705,7 +705,7 @@ inline _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { - return _VSTD::copy(__first, __last, __result); + return _VSTD::copy_backward(__first, __last, __result); } // swap_ranges diff --git a/contrib/libc++/include/__config b/contrib/libc++/include/__config index a8c3498b0..c5b9a6b1c 100644 --- a/contrib/libc++/include/__config +++ b/contrib/libc++/include/__config @@ -19,6 +19,11 @@ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #endif +#if !_WIN32 +#include +#include // for ELAST on FreeBSD +#endif + #define _LIBCPP_VERSION 1101 #define _LIBCPP_ABI_VERSION 1 @@ -106,6 +111,13 @@ # endif #endif // __sun__ +#if defined(__native_client__) + // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, + // including accesses to the special files under /dev. C++11's + // std::random_device is instead exposed through a NaCl syscall. +# define _LIBCPP_USING_NACL_RANDOM +#endif // defined(__native_client__) + #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) # include # if __BYTE_ORDER == __LITTLE_ENDIAN @@ -194,7 +206,7 @@ #endif #ifndef _LIBCPP_EXCEPTION_ABI -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS +#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) #endif #ifndef _LIBCPP_ALWAYS_INLINE @@ -203,6 +215,11 @@ #if defined(__clang__) +#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ + !defined(__arm__) +#define _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif + #if __has_feature(cxx_alignas) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) @@ -215,14 +232,10 @@ #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -#ifdef __linux__ -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#else +#if __cplusplus < 201103L typedef __char16_t char16_t; typedef __char32_t char32_t; #endif -#endif #if !(__has_feature(cxx_exceptions)) #define _LIBCPP_NO_EXCEPTIONS @@ -246,6 +259,8 @@ typedef __char32_t char32_t; # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif +#define _LIBCPP_UNUSED __attribute__((__unused__)) + #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) @@ -308,10 +323,16 @@ typedef __char32_t char32_t; #define _LIBCPP_HAS_NO_CONSTEXPR #endif +#if !(__has_feature(cxx_relaxed_constexpr)) +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#endif + #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L #if defined(__FreeBSD__) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES +#elif defined(__ANDROID__) +#define _LIBCPP_HAS_QUICK_EXIT #elif defined(__linux__) #include #if __GLIBC_PREREQ(2, 15) @@ -326,13 +347,19 @@ typedef __char32_t char32_t; #if (__has_feature(cxx_noexcept)) # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) +# define _NOEXCEPT_OR_FALSE(x) noexcept(x) #else # define _NOEXCEPT throw() # define _NOEXCEPT_(x) +# define _NOEXCEPT_OR_FALSE(x) false #endif #if __has_feature(underlying_type) -# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T) +# define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) +#endif + +#if __has_feature(is_literal) +# define _LIBCPP_IS_LITERAL(T) __is_literal(T) #endif // Inline namespaces are available in Clang regardless of C++ dialect. @@ -345,6 +372,10 @@ namespace std { } } +#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) +#define _LIBCPP_HAS_NO_ASAN +#endif + #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -352,15 +383,33 @@ namespace std { #define _LIBCPP_NORETURN __attribute__((noreturn)) +#define _LIBCPP_UNUSED __attribute__((__unused__)) + +#if _GNUC_VER >= 407 +#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) +#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) +#endif + #if !__EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS #endif #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES + +// constexpr was added to GCC in 4.6. +#if _GNUC_VER < 406 #define _LIBCPP_HAS_NO_CONSTEXPR +// Can only use constexpr in c++11 mode. +#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L +#define _LIBCPP_HAS_NO_CONSTEXPR +#endif + +// No version of GCC supports relaxed constexpr rules +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _NOEXCEPT throw() #define _NOEXCEPT_(x) +#define _NOEXCEPT_OR_FALSE(x) false #ifndef __GXX_EXPERIMENTAL_CXX0X__ @@ -374,6 +423,7 @@ namespace std { #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +#define _LIBCPP_HAS_NO_STRONG_ENUMS #else // __GXX_EXPERIMENTAL_CXX0X__ @@ -389,9 +439,7 @@ namespace std { #endif #if _GNUC_VER < 404 -#define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE -#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS @@ -402,6 +450,11 @@ namespace std { #define _LIBCPP_HAS_NO_NULLPTR #endif +#if _GNUC_VER < 407 +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif + #endif // __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { @@ -414,21 +467,28 @@ namespace _LIBCPP_NAMESPACE { using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); } +#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) +#define _LIBCPP_HAS_NO_ASAN +#endif + #elif defined(_LIBCPP_MSVC) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) +#define _LIBCPP_UNUSED #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS -#define _NOEXCEPT throw() +#define _NOEXCEPT throw () #define _NOEXCEPT_(x) +#define _NOEXCEPT_OR_FALSE(x) false #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } @@ -438,15 +498,19 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); namespace std { } +#define _LIBCPP_HAS_NO_ASAN + #elif defined(__IBMCPP__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ATTRIBUTE(x) __attribute__((x)) #define _LIBCPP_NORETURN __attribute__((noreturn)) +#define _LIBCPP_UNUSED #define _NOEXCEPT throw() #define _NOEXCEPT_(x) +#define _NOEXCEPT_OR_FALSE(x) false #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -454,7 +518,6 @@ namespace std { #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_HAS_IS_BASE_OF #if defined(_AIX) @@ -470,13 +533,19 @@ namespace std { } } -#endif // __clang__ || __GNUC___ || _MSC_VER || __IBMCPP__ +#define _LIBCPP_HAS_NO_ASAN + +#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS +#ifndef __SIZEOF_INT128__ +#define _LIBCPP_HAS_NO_INT128 +#endif + #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT template struct __static_assert_test; @@ -514,12 +583,20 @@ template struct __static_assert_check {}; #define __has_feature(__x) 0 #endif -#if __has_feature(cxx_explicit_conversions) +#ifndef __has_builtin +#define __has_builtin(__x) 0 +#endif + +#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) # define _LIBCPP_EXPLICIT explicit #else # define _LIBCPP_EXPLICIT #endif +#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) +# define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE +#endif + #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ @@ -545,16 +622,21 @@ template struct __static_assert_check {}; #endif #ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #endif #ifndef _LIBCPP_EXTERN_TEMPLATE2 #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif +#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) +#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) +#endif + #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif + #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif @@ -567,21 +649,39 @@ template struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#if defined(__APPLE__) || defined(__FreeBSD__) -#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR -# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0 -#endif +#if defined(ELAST) +#define _LIBCPP_ELAST ELAST +#elif defined(__linux__) +#define _LIBCPP_ELAST 4095 +#elif defined(_NEWLIB_VERSION) +#define _LIBCPP_ELAST __ELASTERROR +#elif defined(__APPLE__) +// Not _LIBCPP_ELAST needed on Apple +#elif defined(__sun__) +#define _LIBCPP_ELAST ESTALE +#else +// Warn here so that the person doing the libcxx port has an easier time: +#warning This platform's ELAST hasn't been ported yet #endif #ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR -# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 +# if defined(__FreeBSD__) +// Making the std::pair copy constructor trivial breaks ABI compatibility with +// earlier versions of libc++ shipped by FreeBSD, so turn it off by default. +// See also http://svnweb.freebsd.org/changeset/base/261801 +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0 +# else +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 +# endif #endif #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 +# elif __cplusplus <= 201402L +# define _LIBCPP_STD_VER 14 # else -# define _LIBCPP_STD_VER 13 // current year, or date of c++14 ratification +# define _LIBCPP_STD_VER 15 // current year, or date of c++17 ratification # endif #endif // _LIBCPP_STD_VER @@ -592,21 +692,30 @@ template struct __static_assert_check {}; #endif #if _LIBCPP_STD_VER <= 11 -#define _LIBCPP_CONSTEXPR_AFTER_CXX11 #define _LIBCPP_EXPLICIT_AFTER_CXX11 #define _LIBCPP_DEPRECATED_AFTER_CXX11 #else -#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] #endif +#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) +#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +#else +#define _LIBCPP_CONSTEXPR_AFTER_CXX11 +#endif + +#ifndef _LIBCPP_HAS_NO_ASAN +extern "C" void __sanitizer_annotate_contiguous_container( + const void *, const void *, const void *, const void *); +#endif + // Try to find out if RTTI is disabled. // g++ and cl.exe have RTTI on by default and define a macro when it is. // g++ only defines the macro in 4.3.2 and onwards. #if !defined(_LIBCPP_NO_RTTI) -# if defined(__GNUG__) && (__GNUC__ >= 4 && \ - (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI) +# if defined(__GNUG__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ + (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) # define _LIBCPP_NO_RTTI @@ -617,4 +726,9 @@ template struct __static_assert_check {}; # define _LIBCPP_WEAK __attribute__((__weak__)) #endif +#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) +# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ + _LIBCPP_HAS_NO_THREADS is defined. +#endif + #endif // _LIBCPP_CONFIG diff --git a/contrib/libc++/include/__debug b/contrib/libc++/include/__debug index f1805adcf..c1512246b 100644 --- a/contrib/libc++/include/__debug +++ b/contrib/libc++/include/__debug @@ -11,19 +11,23 @@ #ifndef _LIBCPP_DEBUG_H #define _LIBCPP_DEBUG_H +#include <__config> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #if _LIBCPP_DEBUG_LEVEL >= 1 - # include # include # include # ifndef _LIBCPP_ASSERT # define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort())) # endif +#endif +#ifndef _LIBCPP_ASSERT +# define _LIBCPP_ASSERT(x, m) ((void)0) #endif #if _LIBCPP_DEBUG_LEVEL >= 2 diff --git a/contrib/libc++/include/__functional_03 b/contrib/libc++/include/__functional_03 index 258260173..d8a9f05fa 100644 --- a/contrib/libc++/include/__functional_03 +++ b/contrib/libc++/include/__functional_03 @@ -651,9 +651,14 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> __base* __f_; template + _LIBCPP_INLINE_VISIBILITY static bool __not_null(const _Fp&) {return true;} template - static bool __not_null(const function<_Rp()>& __p) {return __p;} + _LIBCPP_INLINE_VISIBILITY + static bool __not_null(_R2 (*__p)()) {return __p;} + template + _LIBCPP_INLINE_VISIBILITY + static bool __not_null(const function<_R2()>& __p) {return __p;} public: typedef _Rp result_type; @@ -955,7 +960,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_Rp(_B0)>& __p) {return __p;} + static bool __not_null(const function<_R2(_B0)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1257,7 +1262,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_Rp(_B0, _B1)>& __p) {return __p;} + static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1558,7 +1563,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_Rp(_B0, _B1, _B2)>& __p) {return __p;} + static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1911,7 +1916,7 @@ inline _LIBCPP_INLINE_VISIBILITY typename __mu_return1::type __mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>) { - __ti(_VSTD::forward::type>(get<_Indx>(__uj))...); + __ti(_VSTD::forward::type>(_VSTD::get<_Indx>(__uj))...); } template @@ -1947,9 +1952,9 @@ __mu(_Ti&, _Uj& __uj) { const size_t _Indx = is_placeholder<_Ti>::value - 1; // compiler bug workaround - typename tuple_element<_Indx, _Uj>::type __t = get<_Indx>(__uj); + typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj); return __t; -// return _VSTD::forward::type>(get<_Indx>(__uj)); +// return _VSTD::forward::type>(_VSTD::get<_Indx>(__uj)); } template @@ -2040,7 +2045,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) { - return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...); + return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); } template diff --git a/contrib/libc++/include/__functional_base b/contrib/libc++/include/__functional_base index 1c337d8b4..6766793d7 100644 --- a/contrib/libc++/include/__functional_base +++ b/contrib/libc++/include/__functional_base @@ -451,10 +451,10 @@ public: } }; -template struct ____is_reference_wrapper : public false_type {}; -template struct ____is_reference_wrapper > : public true_type {}; +template struct __is_reference_wrapper_impl : public false_type {}; +template struct __is_reference_wrapper_impl > : public true_type {}; template struct __is_reference_wrapper - : public ____is_reference_wrapper::type> {}; + : public __is_reference_wrapper_impl::type> {}; template inline _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/__functional_base_03 b/contrib/libc++/include/__functional_base_03 index 296dd8db3..22c06add9 100644 --- a/contrib/libc++/include/__functional_base_03 +++ b/contrib/libc++/include/__functional_base_03 @@ -1027,7 +1027,7 @@ public: typename __invoke_return0::type operator() (_A0& __a0) const { - return __invoke(get(), __a0); + return __invoke(get(), __a0); } template @@ -1035,7 +1035,7 @@ public: typename __invoke_return1::type operator() (_A0& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); + return __invoke(get(), __a0, __a1); } template @@ -1043,14 +1043,14 @@ public: typename __invoke_return2::type operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); + return __invoke(get(), __a0, __a1, __a2); } }; -template struct ____is_reference_wrapper : public false_type {}; -template struct ____is_reference_wrapper > : public true_type {}; +template struct __is_reference_wrapper_impl : public false_type {}; +template struct __is_reference_wrapper_impl > : public true_type {}; template struct __is_reference_wrapper - : public ____is_reference_wrapper::type> {}; + : public __is_reference_wrapper_impl::type> {}; template inline _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/__hash_table b/contrib/libc++/include/__hash_table index 4c4feb03e..7c954b680 100644 --- a/contrib/libc++/include/__hash_table +++ b/contrib/libc++/include/__hash_table @@ -20,11 +20,7 @@ #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG -# include <__debug> -#else -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif +#include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/contrib/libc++/include/__locale b/contrib/libc++/include/__locale index 6d75162a9..0097fc28d 100644 --- a/contrib/libc++/include/__locale +++ b/contrib/libc++/include/__locale @@ -21,11 +21,22 @@ #include #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # include -#elif _AIX +#elif defined(_AIX) # include -#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(__EMSCRIPTEN__) || defined(__IBMCPP__) +#elif defined(__ANDROID__) +// Android gained the locale aware functions in L (API level 21) +# include +# if __ANDROID_API__ <= 20 +# include +# endif +#elif defined(__sun__) +# include +#elif defined(_NEWLIB_VERSION) +# include +#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) # include -#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ +#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -341,13 +352,15 @@ public: static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; -#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__ANDROID__) #ifdef __APPLE__ typedef __uint32_t mask; #elif defined(__FreeBSD__) typedef unsigned long mask; #elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) typedef unsigned short mask; +#elif defined(__ANDROID__) + typedef unsigned char mask; #endif static const mask space = _CTYPE_S; static const mask print = _CTYPE_R; @@ -357,7 +370,12 @@ public: static const mask alpha = _CTYPE_A; static const mask digit = _CTYPE_D; static const mask punct = _CTYPE_P; +# if defined(__ANDROID__) + static const mask xdigit = _CTYPE_X | _CTYPE_D; +# else static const mask xdigit = _CTYPE_X; +# endif + # if defined(__NetBSD__) static const mask blank = _CTYPE_BL; # else diff --git a/contrib/libc++/include/__mutex_base b/contrib/libc++/include/__mutex_base index d4023a64f..d5ece7c14 100644 --- a/contrib/libc++/include/__mutex_base +++ b/contrib/libc++/include/__mutex_base @@ -22,6 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_THREADS + class _LIBCPP_TYPE_VIS mutex { pthread_mutex_t __m_; @@ -254,19 +256,13 @@ void swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT {__x.swap(__y);} -struct _LIBCPP_TYPE_VIS cv_status +//enum class cv_status +_LIBCPP_DECLARE_STRONG_ENUM(cv_status) { - enum __lx { - no_timeout, - timeout - }; - - __lx __v_; - - _LIBCPP_INLINE_VISIBILITY cv_status(__lx __v) : __v_(__v) {} - _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} - + no_timeout, + timeout }; +_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) class _LIBCPP_TYPE_VIS condition_variable { @@ -288,7 +284,7 @@ public: void notify_one() _NOEXCEPT; void notify_all() _NOEXCEPT; - void wait(unique_lock& __lk); + void wait(unique_lock& __lk) _NOEXCEPT; template void wait(unique_lock& __lk, _Predicate __pred); @@ -319,8 +315,9 @@ public: private: void __do_timed_wait(unique_lock& __lk, - chrono::time_point); + chrono::time_point) _NOEXCEPT; }; +#endif // !_LIBCPP_HAS_NO_THREADS template inline _LIBCPP_INLINE_VISIBILITY @@ -338,6 +335,7 @@ __ceil(chrono::duration<_Rep, _Period> __d) return __r; } +#ifndef _LIBCPP_HAS_NO_THREADS template void condition_variable::wait(unique_lock& __lk, _Predicate __pred) @@ -402,6 +400,8 @@ condition_variable::wait_for(unique_lock& __lk, _VSTD::move(__pred)); } +#endif // !_LIBCPP_HAS_NO_THREADS + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___MUTEX_BASE diff --git a/contrib/libc++/include/__refstring b/contrib/libc++/include/__refstring new file mode 100644 index 000000000..6866bf1b9 --- /dev/null +++ b/contrib/libc++/include/__refstring @@ -0,0 +1,139 @@ +//===------------------------ __refstring ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___REFSTRING +#define _LIBCPP___REFSTRING + +#include <__config> +#include +#include +#if __APPLE__ +#include +#include +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_HIDDEN __libcpp_refstring +{ +private: + const char* str_; + + typedef int count_t; + + struct _Rep_base + { + std::size_t len; + std::size_t cap; + count_t count; + }; + + static + _Rep_base* + rep_from_data(const char *data_) _NOEXCEPT + { + char *data = const_cast(data_); + return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base)); + } + static + char * + data_from_rep(_Rep_base *rep) _NOEXCEPT + { + char *data = reinterpret_cast(rep); + return data + sizeof(*rep); + } + +#if __APPLE__ + static + const char* + compute_gcc_empty_string_storage() _NOEXCEPT + { + void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD); + if (handle == nullptr) + return nullptr; + void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE"); + if (sym == nullptr) + return nullptr; + return data_from_rep(reinterpret_cast<_Rep_base *>(sym)); + } + + static + const char* + get_gcc_empty_string_storage() _NOEXCEPT + { + static const char* p = compute_gcc_empty_string_storage(); + return p; + } + + bool + uses_refcount() const + { + return str_ != get_gcc_empty_string_storage(); + } +#else + bool + uses_refcount() const + { + return true; + } +#endif + +public: + explicit __libcpp_refstring(const char* msg) { + std::size_t len = strlen(msg); + _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1)); + rep->len = len; + rep->cap = len; + rep->count = 0; + char *data = data_from_rep(rep); + std::memcpy(data, msg, len + 1); + str_ = data; + } + + __libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_) + { + if (uses_refcount()) + __sync_add_and_fetch(&rep_from_data(str_)->count, 1); + } + + __libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT + { + bool adjust_old_count = uses_refcount(); + struct _Rep_base *old_rep = rep_from_data(str_); + str_ = s.str_; + if (uses_refcount()) + __sync_add_and_fetch(&rep_from_data(str_)->count, 1); + if (adjust_old_count) + { + if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0) + { + ::operator delete(old_rep); + } + } + return *this; + } + + ~__libcpp_refstring() + { + if (uses_refcount()) + { + _Rep_base* rep = rep_from_data(str_); + if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) + { + ::operator delete(rep); + } + } + } + + const char* c_str() const _NOEXCEPT {return str_;} +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif //_LIBCPP___REFSTRING diff --git a/contrib/libc++/include/__sso_allocator b/contrib/libc++/include/__sso_allocator index 7240072ca..645f2ba17 100644 --- a/contrib/libc++/include/__sso_allocator +++ b/contrib/libc++/include/__sso_allocator @@ -55,14 +55,14 @@ public: __allocated_ = true; return (pointer)&buf_; } - return static_cast(::operator new(__n * sizeof(_Tp))); + return static_cast(_VSTD::__allocate(__n * sizeof(_Tp))); } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) { if (__p == (pointer)&buf_) __allocated_ = false; else - ::operator delete(__p); + _VSTD::__deallocate(__p); } _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} diff --git a/contrib/libc++/include/__tree b/contrib/libc++/include/__tree index acf87593a..8e5447a2f 100644 --- a/contrib/libc++/include/__tree +++ b/contrib/libc++/include/__tree @@ -1980,9 +1980,9 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) __begin_node() = __r.__ptr_; --size(); __node_allocator& __na = __node_alloc(); - __node_traits::destroy(__na, const_cast(_VSTD::addressof(*__p))); __tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); + __node_traits::destroy(__na, const_cast(_VSTD::addressof(*__p))); __node_traits::deallocate(__na, __np, 1); return __r; } diff --git a/contrib/libc++/include/__tuple b/contrib/libc++/include/__tuple index de35cb87e..bffb95cb7 100644 --- a/contrib/libc++/include/__tuple +++ b/contrib/libc++/include/__tuple @@ -27,6 +27,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// __lazy_and + +template +struct __lazy_and_impl; + +template +struct __lazy_and_impl : false_type {}; + +template <> +struct __lazy_and_impl : true_type {}; + +template +struct __lazy_and_impl : integral_constant {}; + +template +struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template +struct __lazy_not : integral_constant {}; + + template class _LIBCPP_TYPE_VIS_ONLY tuple_size; template @@ -219,19 +245,30 @@ struct __make_tuple_types // __tuple_convertible -template +template struct __tuple_convertible_imp : public false_type {}; template -struct __tuple_convertible_imp, __tuple_types<_Up0, _Up...> > +struct __tuple_convertible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> > : public integral_constant::value && - __tuple_convertible_imp, __tuple_types<_Up...> >::value> {}; + __tuple_convertible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {}; template <> -struct __tuple_convertible_imp, __tuple_types<> > +struct __tuple_convertible_imp<__tuple_types<>, __tuple_types<> > : public true_type {}; +template +struct __tuple_convertible_apply : public false_type {}; + +template +struct __tuple_convertible_apply + : public __tuple_convertible_imp< + typename __make_tuple_types<_Tp>::type + , typename __make_tuple_types<_Up>::type + > +{}; + template ::type>::value, bool = __tuple_like<_Up>::value> struct __tuple_convertible @@ -239,26 +276,36 @@ struct __tuple_convertible template struct __tuple_convertible<_Tp, _Up, true, true> - : public __tuple_convertible_imp::type>::value == - tuple_size<_Up>::value, - typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> + : public __tuple_convertible_apply::type>::value == + tuple_size<_Up>::value, _Tp, _Up> {}; // __tuple_constructible -template +template struct __tuple_constructible_imp : public false_type {}; template -struct __tuple_constructible_imp, __tuple_types<_Up0, _Up...> > +struct __tuple_constructible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> > : public integral_constant::value && - __tuple_constructible_imp, __tuple_types<_Up...> >::value> {}; + __tuple_constructible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {}; template <> -struct __tuple_constructible_imp, __tuple_types<> > +struct __tuple_constructible_imp<__tuple_types<>, __tuple_types<> > : public true_type {}; +template +struct __tuple_constructible_apply : public false_type {}; + +template +struct __tuple_constructible_apply + : public __tuple_constructible_imp< + typename __make_tuple_types<_Tp>::type + , typename __make_tuple_types<_Up>::type + > +{}; + template ::type>::value, bool = __tuple_like<_Up>::value> struct __tuple_constructible @@ -266,26 +313,36 @@ struct __tuple_constructible template struct __tuple_constructible<_Tp, _Up, true, true> - : public __tuple_constructible_imp::type>::value == - tuple_size<_Up>::value, - typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> + : public __tuple_constructible_apply::type>::value == + tuple_size<_Up>::value, _Tp, _Up> {}; // __tuple_assignable -template +template struct __tuple_assignable_imp : public false_type {}; template -struct __tuple_assignable_imp, __tuple_types<_Up0, _Up...> > +struct __tuple_assignable_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> > : public integral_constant::value && - __tuple_assignable_imp, __tuple_types<_Up...> >::value> {}; + __tuple_assignable_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {}; template <> -struct __tuple_assignable_imp, __tuple_types<> > +struct __tuple_assignable_imp<__tuple_types<>, __tuple_types<> > : public true_type {}; +template +struct __tuple_assignable_apply : public false_type {}; + +template +struct __tuple_assignable_apply + : __tuple_assignable_imp< + typename __make_tuple_types<_Tp>::type + , typename __make_tuple_types<_Up>::type + > +{}; + template ::type>::value, bool = __tuple_like<_Up>::value> struct __tuple_assignable @@ -293,9 +350,8 @@ struct __tuple_assignable template struct __tuple_assignable<_Tp, _Up, true, true> - : public __tuple_assignable_imp::type>::value == - tuple_size<_Up>::value, - typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> + : public __tuple_assignable_apply::type>::value == + tuple_size<_Up>::value, _Tp, _Up> {}; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/algorithm b/contrib/libc++/include/algorithm index 367489fbb..02cbc816f 100644 --- a/contrib/libc++/include/algorithm +++ b/contrib/libc++/include/algorithm @@ -281,11 +281,12 @@ template template void - random_shuffle(RandomAccessIterator first, RandomAccessIterator last); + random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14 template void - random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand); + random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + RandomNumberGenerator& rand); // deprecated in C++14 template void shuffle(RandomAccessIterator first, RandomAccessIterator last, @@ -528,19 +529,19 @@ template template const T& - min(const T& a, const T& b); + min(const T& a, const T& b); // constexpr in C++14 template const T& - min(const T& a, const T& b, Compare comp); + min(const T& a, const T& b, Compare comp); // constexpr in C++14 template T - min(initializer_list t); + min(initializer_list t); // constexpr in C++14 template T - min(initializer_list t, Compare comp); + min(initializer_list t, Compare comp); // constexpr in C++14 template ForwardIterator @@ -552,19 +553,19 @@ template template const T& - max(const T& a, const T& b); + max(const T& a, const T& b); // constexpr in C++14 template const T& - max(const T& a, const T& b, Compare comp); + max(const T& a, const T& b, Compare comp); // constexpr in C++14 template T - max(initializer_list t); + max(initializer_list t); // constexpr in C++14 template T - max(initializer_list t, Compare comp); + max(initializer_list t, Compare comp); // constexpr in C++14 template pair @@ -576,19 +577,19 @@ template template pair - minmax(const T& a, const T& b); + minmax(const T& a, const T& b); // constexpr in C++14 template pair - minmax(const T& a, const T& b, Compare comp); + minmax(const T& a, const T& b, Compare comp); // constexpr in C++14 template pair - minmax(initializer_list t); + minmax(initializer_list t); // constexpr in C++14 template pair - minmax(initializer_list t, Compare comp); + minmax(initializer_list t, Compare comp); // constexpr in C++14 template bool @@ -637,12 +638,17 @@ template #include <__undef_min_max> +#include <__debug> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD +// I'd like to replace these with _VSTD::equal_to, but can't because: +// * That only works with C++14 and later, and +// * We haven't included here. template struct __equal_to { @@ -655,46 +661,59 @@ struct __equal_to template struct __equal_to<_T1, _T1> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __equal_to { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __equal_to<_T1, const _T1> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __less { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} }; template struct __less<_T1, _T1> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template struct __less { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template struct __less<_T1, const _T1> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template @@ -958,7 +977,7 @@ __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, } template -_RandomAccessIterator1 +_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) @@ -1024,8 +1043,8 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, // find_first_of template -_ForwardIterator1 -find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, +_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 +__find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { for (; __first1 != __last1; ++__first1) @@ -1035,6 +1054,16 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, return __last1; } + +template +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator1 +find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) +{ + return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred); +} + template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 @@ -1043,7 +1072,7 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, { typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; - return _VSTD::find_first_of(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); + return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); } // adjacent_find @@ -1111,7 +1140,7 @@ pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) break; return pair<_InputIterator1, _InputIterator2>(__first1, __first2); @@ -1135,7 +1164,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred) { - for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) break; return pair<_InputIterator1, _InputIterator2>(__first1, __first2); @@ -1160,7 +1189,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) return false; return true; @@ -1184,7 +1213,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag ) { - for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) return false; return __first1 == __last1 && __first2 == __last2; @@ -1238,7 +1267,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { // shorten sequences as much as possible by lopping of any equal parts - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) goto __not_done; return true; @@ -1298,7 +1327,7 @@ __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, forward_iterator_tag, forward_iterator_tag ) { // shorten sequences as much as possible by lopping of any equal parts - for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2) if (!__pred(*__first1, *__first2)) goto __not_done; return __first1 == __last1 && __first2 == __last2; @@ -1423,7 +1452,7 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template -_RandomAccessIterator1 +_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) @@ -1716,7 +1745,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - for (; __first != __last; ++__first, ++__result) + for (; __first != __last; ++__first, (void) ++__result) *__result = *__first; return __result; } @@ -1845,7 +1874,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - for (; __first != __last; ++__first, ++__result) + for (; __first != __last; ++__first, (void) ++__result) *__result = _VSTD::move(*__first); return __result; } @@ -1921,7 +1950,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op) { - for (; __first != __last; ++__first, ++__result) + for (; __first != __last; ++__first, (void) ++__result) *__result = __op(*__first); return __result; } @@ -1932,7 +1961,7 @@ _OutputIterator transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _BinaryOperation __binary_op) { - for (; __first1 != __last1; ++__first1, ++__first2, ++__result) + for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result) *__result = __binary_op(*__first1, *__first2); return __result; } @@ -1969,7 +1998,7 @@ _OutputIterator replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __old_value, const _Tp& __new_value) { - for (; __first != __last; ++__first, ++__result) + for (; __first != __last; ++__first, (void) ++__result) if (*__first == __old_value) *__result = __new_value; else @@ -1985,7 +2014,7 @@ _OutputIterator replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred, const _Tp& __new_value) { - for (; __first != __last; ++__first, ++__result) + for (; __first != __last; ++__first, (void) ++__result) if (__pred(*__first)) *__result = __new_value; else @@ -2000,7 +2029,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { - for (; __n > 0; ++__first, --__n) + for (; __n > 0; ++__first, (void) --__n) *__first = __value_; return __first; } @@ -2074,7 +2103,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator generate_n(_OutputIterator __first, _Size __n, _Generator __gen) { - for (; __n > 0; ++__first, --__n) + for (; __n > 0; ++__first, (void) --__n) *__first = __gen(); return __first; } @@ -2505,9 +2534,9 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato // min_element template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { @@ -2519,19 +2548,27 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) return __first; } +template +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator +min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + return __min_element(__first, __last, __comp); +} + template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { - return _VSTD::min_element(__first, __last, + return __min_element(__first, __last, __less::value_type>()); } // min template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2539,7 +2576,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& min(const _Tp& __a, const _Tp& __b) { @@ -2549,19 +2586,19 @@ min(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t, _Compare __comp) { - return *_VSTD::min_element(__t.begin(), __t.end(), __comp); + return *__min_element(__t.begin(), __t.end(), __comp); } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t) { - return *_VSTD::min_element(__t.begin(), __t.end()); + return *__min_element(__t.begin(), __t.end(), __less<_Tp>()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2569,9 +2606,9 @@ min(initializer_list<_Tp> __t) // max_element template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { @@ -2583,19 +2620,28 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) return __first; } + +template +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator +max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + return __max_element(__first, __last, __comp); +} + template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { - return _VSTD::max_element(__first, __last, + return __max_element(__first, __last, __less::value_type>()); } // max template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2603,7 +2649,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& max(const _Tp& __a, const _Tp& __b) { @@ -2613,19 +2659,19 @@ max(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t, _Compare __comp) { - return *_VSTD::max_element(__t.begin(), __t.end(), __comp); + return *__max_element(__t.begin(), __t.end(), __comp); } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t) { - return *_VSTD::max_element(__t.begin(), __t.end()); + return *__max_element(__t.begin(), __t.end(), __less<_Tp>()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2684,13 +2730,14 @@ inline _LIBCPP_INLINE_VISIBILITY std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { - return _VSTD::minmax_element(__first, __last, __less::value_type>()); + return _VSTD::minmax_element(__first, __last, + __less::value_type>()); } // minmax template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2699,7 +2746,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair minmax(const _Tp& __a, const _Tp& __b) { @@ -2708,24 +2755,49 @@ minmax(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -template -inline _LIBCPP_INLINE_VISIBILITY +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Tp, _Tp> -minmax(initializer_list<_Tp> __t) +minmax(initializer_list<_Tp> __t, _Compare __comp) { - pair __p = - _VSTD::minmax_element(__t.begin(), __t.end()); - return pair<_Tp, _Tp>(*__p.first, *__p.second); + typedef typename initializer_list<_Tp>::const_iterator _Iter; + _Iter __first = __t.begin(); + _Iter __last = __t.end(); + std::pair<_Tp, _Tp> __result ( *__first, *__first ); + + ++__first; + if (__t.size() % 2 == 0) + { + if (__comp(*__first, __result.first)) + __result.first = *__first; + else + __result.second = *__first; + ++__first; + } + + while (__first != __last) + { + _Tp __prev = *__first++; + if (__comp(__prev, *__first)) { + if (__comp(__prev, __result.first)) __result.first = __prev; + if (__comp(__result.second, *__first)) __result.second = *__first; + } + else { + if (__comp(*__first, __result.first)) __result.first = *__first; + if (__comp(__result.second, __prev)) __result.second = __prev; + } + + __first++; + } + return __result; } -template -inline _LIBCPP_INLINE_VISIBILITY +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Tp, _Tp> -minmax(initializer_list<_Tp> __t, _Compare __comp) +minmax(initializer_list<_Tp> __t) { - pair __p = - _VSTD::minmax_element(__t.begin(), __t.end(), __comp); - return pair<_Tp, _Tp>(*__p.first, *__p.second); + return _VSTD::minmax(__t, __less<_Tp>()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -4300,7 +4372,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator if (__len1 <= __len2) { value_type* __p = __buff; - for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), ++__i, ++__p) + for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p) ::new(__p) value_type(_VSTD::move(*__i)); __merge<_Compare>(move_iterator(__buff), move_iterator(__p), @@ -4311,7 +4383,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator else { value_type* __p = __buff; - for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), ++__i, ++__p) + for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, ++__p) ::new(__p) value_type(_VSTD::move(*__i)); typedef reverse_iterator<_BidirectionalIterator> _RBi; typedef reverse_iterator _Rv; @@ -4336,7 +4408,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, if (__len2 == 0) return; // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 - for (; true; ++__first, --__len1) + for (; true; ++__first, (void) --__len1) { if (__len1 == 0) return; @@ -4724,49 +4796,8 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) template void -__push_heap_front(_RandomAccessIterator __first, _RandomAccessIterator, _Compare __comp, - typename iterator_traits<_RandomAccessIterator>::difference_type __len) -{ - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; - typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; - if (__len > 1) - { - difference_type __p = 0; - _RandomAccessIterator __pp = __first; - difference_type __c = 2; - _RandomAccessIterator __cp = __first + __c; - if (__c == __len || __comp(*__cp, *(__cp - 1))) - { - --__c; - --__cp; - } - if (__comp(*__pp, *__cp)) - { - value_type __t(_VSTD::move(*__pp)); - do - { - *__pp = _VSTD::move(*__cp); - __pp = __cp; - __p = __c; - __c = (__p + 1) * 2; - if (__c > __len) - break; - __cp = __first + __c; - if (__c == __len || __comp(*__cp, *(__cp - 1))) - { - --__c; - --__cp; - } - } while (__comp(__t, *__cp)); - *__pp = _VSTD::move(__t); - } - } -} - -template -void -__push_heap_back(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, - typename iterator_traits<_RandomAccessIterator>::difference_type __len) +__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; @@ -4799,10 +4830,10 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); - __push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first); + __sift_up<_Comp_ref>(__first, __last, __c, __last - __first); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first); + __sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); #endif // _LIBCPP_DEBUG } @@ -4816,6 +4847,60 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) // pop_heap +template +void +__sift_down(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len, + _RandomAccessIterator __start) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + // left-child of __start is at 2 * __start + 1 + // right-child of __start is at 2 * __start + 2 + difference_type __child = __start - __first; + + if (__len < 2 || (__len - 2) / 2 < __child) + return; + + __child = 2 * __child + 1; + _RandomAccessIterator __child_i = __first + __child; + + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { + // right-child exists and is greater than left-child + ++__child_i; + ++__child; + } + + // check if we are in heap-order + if (__comp(*__child_i, *__start)) + // we are, __start is larger than it's largest child + return; + + value_type __top(_VSTD::move(*__start)); + do + { + // we are not in heap-order, swap the parent with it's largest child + *__start = _VSTD::move(*__child_i); + __start = __child_i; + + if ((__len - 2) / 2 < __child) + break; + + // recompute the child based off of the updated parent + __child = 2 * __child + 1; + __child_i = __first + __child; + + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { + // right-child exists and is greater than left-child + ++__child_i; + ++__child; + } + + // check if we are in heap-order + } while (!__comp(*__child_i, __top)); + *__start = _VSTD::move(__top); +} + template inline _LIBCPP_INLINE_VISIBILITY void @@ -4825,7 +4910,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare if (__len > 1) { swap(*__first, *--__last); - __push_heap_front<_Compare>(__first, __last, __comp, __len-1); + __sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); } } @@ -4862,10 +4947,11 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar difference_type __n = __last - __first; if (__n > 1) { - __last = __first; - ++__last; - for (difference_type __i = 1; __i < __n;) - __push_heap_back<_Compare>(__first, ++__last, __comp, ++__i); + // start from the first parent, there is no need to consider children + for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) + { + __sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); + } } } @@ -4940,7 +5026,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R if (__comp(*__i, *__first)) { swap(*__i, *__first); - __push_heap_front<_Compare>(__first, __middle, __comp, __len); + __sift_down<_Compare>(__first, __middle, __comp, __len, __first); } } __sort_heap<_Compare>(__first, __middle, __comp); @@ -4981,15 +5067,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __r = __result_first; if (__r != __result_last) { - typename iterator_traits<_RandomAccessIterator>::difference_type __len = 0; - for (; __first != __last && __r != __result_last; ++__first, ++__r, ++__len) + for (; __first != __last && __r != __result_last; (void) ++__first, ++__r) *__r = *__first; __make_heap<_Compare>(__result_first, __r, __comp); + typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first; for (; __first != __last; ++__first) if (__comp(*__first, *__result_first)) { *__result_first = *__first; - __push_heap_front<_Compare>(__result_first, __r, __comp, __len); + __sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); } __sort_heap<_Compare>(__result_first, __r, __comp); } @@ -5503,7 +5589,7 @@ bool __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { - for (; __first2 != __last2; ++__first1, ++__first2) + for (; __first2 != __last2; ++__first1, (void) ++__first2) { if (__first1 == __last1 || __comp(*__first1, *__first2)) return true; diff --git a/contrib/libc++/include/atomic b/contrib/libc++/include/atomic index f6ab1cbaf..b01a59f5f 100644 --- a/contrib/libc++/include/atomic +++ b/contrib/libc++/include/atomic @@ -533,9 +533,13 @@ void atomic_signal_fence(memory_order m) noexcept; #pragma GCC system_header #endif +#ifdef _LIBCPP_HAS_NO_THREADS +#error is not supported on this single threaded system +#else // !_LIBCPP_HAS_NO_THREADS + _LIBCPP_BEGIN_NAMESPACE_STD -#if !__has_feature(cxx_atomic) +#if !__has_feature(cxx_atomic) && _GNUC_VER < 407 #error is not implemented #else @@ -545,6 +549,257 @@ typedef enum memory_order memory_order_release, memory_order_acq_rel, memory_order_seq_cst } memory_order; +#if _GNUC_VER >= 407 +namespace __gcc_atomic { +template +struct __gcc_atomic_t { + __gcc_atomic_t() _NOEXCEPT {} + explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {} + T __a_value; +}; +#define _Atomic(x) __gcc_atomic::__gcc_atomic_t + +template T __create(); + +template +typename enable_if__a_value = __create<__Td>()), char>::type + __test_atomic_assignable(int); +template +__two __test_atomic_assignable(...); + +template +struct __can_assign { + static const bool value = + sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char); +}; + +static inline constexpr int __to_gcc_order(memory_order __order) { + // Avoid switch statement to make this a constexpr. + return __order == memory_order_relaxed ? __ATOMIC_RELAXED: + (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: + (__order == memory_order_release ? __ATOMIC_RELEASE: + (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: + (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL: + __ATOMIC_CONSUME)))); +} + +} // namespace __gcc_atomic + +template +static inline +typename enable_if< + __gcc_atomic::__can_assign::value>::type +__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { + __a->__a_value = __val; +} + +template +static inline +typename enable_if< + !__gcc_atomic::__can_assign::value && + __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type +__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) { + // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because + // the default operator= in an object is not volatile, a byte-by-byte copy + // is required. + volatile char* to = reinterpret_cast(&__a->__a_value); + volatile char* end = to + sizeof(_Tp); + char* from = reinterpret_cast(&__val); + while (to != end) { + *to++ = *from++; + } +} + +template +static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) { + __a->__a_value = __val; +} + +static inline void __c11_atomic_thread_fence(memory_order __order) { + __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order)); +} + +static inline void __c11_atomic_signal_fence(memory_order __order) { + __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); +} + +static inline bool __c11_atomic_is_lock_free(size_t __size) { + return __atomic_is_lock_free(__size, 0); +} + +template +static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, + memory_order __order) { + return __atomic_store(&__a->__a_value, &__val, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, + memory_order __order) { + return __atomic_store(&__a->__a_value, &__val, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, + memory_order __order) { + _Tp __ret; + __atomic_load(&__a->__a_value, &__ret, + __gcc_atomic::__to_gcc_order(__order)); + return __ret; +} + +template +static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) { + _Tp __ret; + __atomic_load(&__a->__a_value, &__ret, + __gcc_atomic::__to_gcc_order(__order)); + return __ret; +} + +template +static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a, + _Tp __value, memory_order __order) { + _Tp __ret; + __atomic_exchange(&__a->__a_value, &__value, &__ret, + __gcc_atomic::__to_gcc_order(__order)); + return __ret; +} + +template +static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value, + memory_order __order) { + _Tp __ret; + __atomic_exchange(&__a->__a_value, &__value, &__ret, + __gcc_atomic::__to_gcc_order(__order)); + return __ret; +} + +template +static inline bool __c11_atomic_compare_exchange_strong( + volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, + memory_order __success, memory_order __failure) { + return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, + false, + __gcc_atomic::__to_gcc_order(__success), + __gcc_atomic::__to_gcc_order(__failure)); +} + +template +static inline bool __c11_atomic_compare_exchange_strong( + _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, + memory_order __failure) { + return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, + false, + __gcc_atomic::__to_gcc_order(__success), + __gcc_atomic::__to_gcc_order(__failure)); +} + +template +static inline bool __c11_atomic_compare_exchange_weak( + volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, + memory_order __success, memory_order __failure) { + return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, + true, + __gcc_atomic::__to_gcc_order(__success), + __gcc_atomic::__to_gcc_order(__failure)); +} + +template +static inline bool __c11_atomic_compare_exchange_weak( + _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success, + memory_order __failure) { + return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, + true, + __gcc_atomic::__to_gcc_order(__success), + __gcc_atomic::__to_gcc_order(__failure)); +} + +template +struct __skip_amt { enum {value = 1}; }; + +template +struct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; }; + +// FIXME: Haven't figured out what the spec says about using arrays with +// atomic_fetch_add. Force a failure rather than creating bad behavior. +template +struct __skip_amt<_Tp[]> { }; +template +struct __skip_amt<_Tp[n]> { }; + +template +static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a, + _Td __delta, memory_order __order) { + return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta, + memory_order __order) { + return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a, + _Td __delta, memory_order __order) { + return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta, + memory_order __order) { + return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a, + _Tp __pattern, memory_order __order) { + return __atomic_fetch_and(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a, + _Tp __pattern, memory_order __order) { + return __atomic_fetch_and(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a, + _Tp __pattern, memory_order __order) { + return __atomic_fetch_or(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern, + memory_order __order) { + return __atomic_fetch_or(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a, + _Tp __pattern, memory_order __order) { + return __atomic_fetch_xor(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} + +template +static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, + memory_order __order) { + return __atomic_fetch_xor(&__a->__a_value, __pattern, + __gcc_atomic::__to_gcc_order(__order)); +} +#endif // _GNUC_VER >= 407 + template inline _LIBCPP_INLINE_VISIBILITY _Tp @@ -1528,4 +1783,6 @@ typedef atomic atomic_uintmax_t; _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_THREADS + #endif // _LIBCPP_ATOMIC diff --git a/contrib/libc++/include/bitset b/contrib/libc++/include/bitset index 4cc7dbdae..8c278cc72 100644 --- a/contrib/libc++/include/bitset +++ b/contrib/libc++/include/bitset @@ -249,9 +249,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR -#if __SIZE_WIDTH__ == 64 +#if __SIZEOF_SIZE_T__ == 8 : __first_{__v} -#elif __SIZE_WIDTH__ == 32 +#elif __SIZEOF_SIZE_T__ == 4 : __first_{__v, __v >> __bits_per_word} #else #error This constructor has not been ported to this platform diff --git a/contrib/libc++/include/chrono b/contrib/libc++/include/chrono index 2c65eee7d..9229234ce 100644 --- a/contrib/libc++/include/chrono +++ b/contrib/libc++/include/chrono @@ -926,6 +926,7 @@ public: static time_point from_time_t(time_t __t) _NOEXCEPT; }; +#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK class _LIBCPP_TYPE_VIS steady_clock { public: @@ -939,6 +940,9 @@ public: }; typedef steady_clock high_resolution_clock; +#else +typedef system_clock high_resolution_clock; +#endif } // chrono diff --git a/contrib/libc++/include/cmath b/contrib/libc++/include/cmath index 75087ae78..d3aa4beeb 100644 --- a/contrib/libc++/include/cmath +++ b/contrib/libc++/include/cmath @@ -316,9 +316,9 @@ long double truncl(long double x); template _LIBCPP_ALWAYS_INLINE bool -__libcpp_signbit(_A1 __x) _NOEXCEPT +__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT { - return signbit(__x); + return signbit(__lcpp_x); } #undef signbit @@ -326,9 +326,9 @@ __libcpp_signbit(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, bool>::type -signbit(_A1 __x) _NOEXCEPT +signbit(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_signbit((typename std::__promote<_A1>::type)__x); + return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); } #endif // signbit @@ -340,9 +340,9 @@ signbit(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE int -__libcpp_fpclassify(_A1 __x) _NOEXCEPT +__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT { - return fpclassify(__x); + return fpclassify(__lcpp_x); } #undef fpclassify @@ -350,9 +350,9 @@ __libcpp_fpclassify(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, int>::type -fpclassify(_A1 __x) _NOEXCEPT +fpclassify(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_fpclassify((typename std::__promote<_A1>::type)__x); + return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); } #endif // fpclassify @@ -364,9 +364,9 @@ fpclassify(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isfinite(_A1 __x) _NOEXCEPT +__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT { - return isfinite(__x); + return isfinite(__lcpp_x); } #undef isfinite @@ -374,9 +374,9 @@ __libcpp_isfinite(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, bool>::type -isfinite(_A1 __x) _NOEXCEPT +isfinite(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_isfinite((typename std::__promote<_A1>::type)__x); + return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); } #endif // isfinite @@ -388,9 +388,9 @@ isfinite(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isinf(_A1 __x) _NOEXCEPT +__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT { - return isinf(__x); + return isinf(__lcpp_x); } #undef isinf @@ -398,9 +398,9 @@ __libcpp_isinf(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, bool>::type -isinf(_A1 __x) _NOEXCEPT +isinf(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_isinf((typename std::__promote<_A1>::type)__x); + return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); } #endif // isinf @@ -412,9 +412,9 @@ isinf(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isnan(_A1 __x) _NOEXCEPT +__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT { - return isnan(__x); + return isnan(__lcpp_x); } #undef isnan @@ -422,9 +422,9 @@ __libcpp_isnan(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, bool>::type -isnan(_A1 __x) _NOEXCEPT +isnan(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_isnan((typename std::__promote<_A1>::type)__x); + return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); } #endif // isnan @@ -436,9 +436,9 @@ isnan(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isnormal(_A1 __x) _NOEXCEPT +__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT { - return isnormal(__x); + return isnormal(__lcpp_x); } #undef isnormal @@ -446,9 +446,9 @@ __libcpp_isnormal(_A1 __x) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY typename std::enable_if::value, bool>::type -isnormal(_A1 __x) _NOEXCEPT +isnormal(_A1 __lcpp_x) _NOEXCEPT { - return __libcpp_isnormal((typename std::__promote<_A1>::type)__x); + return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); } #endif // isnormal @@ -460,9 +460,9 @@ isnormal(_A1 __x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return isgreater(__x, __y); + return isgreater(__lcpp_x, __lcpp_y); } #undef isgreater @@ -475,10 +475,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -isgreater(_A1 __x, _A2 __y) _NOEXCEPT +isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreater((type)__x, (type)__y); + return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); } #endif // isgreater @@ -490,9 +490,9 @@ isgreater(_A1 __x, _A2 __y) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return isgreaterequal(__x, __y); + return isgreaterequal(__lcpp_x, __lcpp_y); } #undef isgreaterequal @@ -505,10 +505,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT +isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreaterequal((type)__x, (type)__y); + return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); } #endif // isgreaterequal @@ -520,9 +520,9 @@ isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return isless(__x, __y); + return isless(__lcpp_x, __lcpp_y); } #undef isless @@ -535,10 +535,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -isless(_A1 __x, _A2 __y) _NOEXCEPT +isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isless((type)__x, (type)__y); + return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); } #endif // isless @@ -550,9 +550,9 @@ isless(_A1 __x, _A2 __y) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return islessequal(__x, __y); + return islessequal(__lcpp_x, __lcpp_y); } #undef islessequal @@ -565,10 +565,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -islessequal(_A1 __x, _A2 __y) _NOEXCEPT +islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessequal((type)__x, (type)__y); + return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); } #endif // islessequal @@ -580,9 +580,9 @@ islessequal(_A1 __x, _A2 __y) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return islessgreater(__x, __y); + return islessgreater(__lcpp_x, __lcpp_y); } #undef islessgreater @@ -595,10 +595,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -islessgreater(_A1 __x, _A2 __y) _NOEXCEPT +islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessgreater((type)__x, (type)__y); + return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); } #endif // islessgreater @@ -610,9 +610,9 @@ islessgreater(_A1 __x, _A2 __y) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE bool -__libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT +__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return isunordered(__x, __y); + return isunordered(__lcpp_x, __lcpp_y); } #undef isunordered @@ -625,10 +625,10 @@ typename std::enable_if std::is_arithmetic<_A2>::value, bool >::type -isunordered(_A1 __x, _A2 __y) _NOEXCEPT +isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isunordered((type)__x, (type)__y); + return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); } #endif // isunordered @@ -657,15 +657,15 @@ using ::double_t; #if !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY float -abs(float __x) _NOEXCEPT {return fabsf(__x);} +abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY double -abs(double __x) _NOEXCEPT {return fabs(__x);} +abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double -abs(long double __x) _NOEXCEPT {return fabsl(__x);} +abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} #endif // !defined(_AIX) #ifndef __sun__ @@ -676,14 +676,14 @@ using ::acos; using ::acosf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) _NOEXCEPT {return acosf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -acos(_A1 __x) _NOEXCEPT {return acos((double)__x);} +acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);} // asin @@ -691,14 +691,14 @@ using ::asin; using ::asinf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) _NOEXCEPT {return asinf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -asin(_A1 __x) _NOEXCEPT {return asin((double)__x);} +asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);} // atan @@ -706,14 +706,14 @@ using ::atan; using ::atanf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) _NOEXCEPT {return atanf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -atan(_A1 __x) _NOEXCEPT {return atan((double)__x);} +atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);} // atan2 @@ -721,24 +721,24 @@ using ::atan2; using ::atan2f; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) _NOEXCEPT {return atan2f(__y, __x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __x);} +inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -atan2(_A1 __y, _A2 __x) _NOEXCEPT +atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return atan2((__result_type)__y, (__result_type)__x); + return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); } // ceil @@ -747,14 +747,14 @@ using ::ceil; using ::ceilf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) _NOEXCEPT {return ceilf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);} +inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -ceil(_A1 __x) _NOEXCEPT {return ceil((double)__x);} +ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);} // cos @@ -762,14 +762,14 @@ using ::cos; using ::cosf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) _NOEXCEPT {return cosf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} +cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);} // cosh @@ -777,14 +777,14 @@ using ::cosh; using ::coshf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) _NOEXCEPT {return coshf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -cosh(_A1 __x) _NOEXCEPT {return cosh((double)__x);} +cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);} #endif // __sun__ // exp @@ -795,15 +795,15 @@ using ::expf; #ifndef __sun__ #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) _NOEXCEPT {return expf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -exp(_A1 __x) _NOEXCEPT {return exp((double)__x);} +exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);} // fabs @@ -811,14 +811,14 @@ using ::fabs; using ::fabsf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) _NOEXCEPT {return fabsf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -fabs(_A1 __x) _NOEXCEPT {return fabs((double)__x);} +fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);} // floor @@ -826,14 +826,14 @@ using ::floor; using ::floorf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) _NOEXCEPT {return floorf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -floor(_A1 __x) _NOEXCEPT {return floor((double)__x);} +floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);} // fmod @@ -843,24 +843,24 @@ using ::fmodf; #ifndef __sun__ #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) _NOEXCEPT {return fmodf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} #endif template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -fmod(_A1 __x, _A2 __y) _NOEXCEPT +fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return fmod((__result_type)__x, (__result_type)__y); + return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); } @@ -870,14 +870,14 @@ using ::frexp; using ::frexpf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) _NOEXCEPT {return frexpf(__x, __e);} -inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);} +inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -frexp(_A1 __x, int* __e) _NOEXCEPT {return frexp((double)__x, __e);} +frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);} // ldexp @@ -885,14 +885,14 @@ using ::ldexp; using ::ldexpf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) _NOEXCEPT {return ldexpf(__x, __e);} -inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);} +inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -ldexp(_A1 __x, int __e) _NOEXCEPT {return ldexp((double)__x, __e);} +ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);} // log @@ -902,14 +902,14 @@ using ::logf; #ifndef __sun__ #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log(float __x) _NOEXCEPT {return logf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -log(_A1 __x) _NOEXCEPT {return log((double)__x);} +log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);} // log10 @@ -918,14 +918,14 @@ using ::log10; using ::log10f; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) _NOEXCEPT {return log10f(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);} +inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -log10(_A1 __x) _NOEXCEPT {return log10((double)__x);} +log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);} // modf @@ -933,8 +933,8 @@ using ::modf; using ::modff; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) _NOEXCEPT {return modff(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} #endif // pow @@ -946,41 +946,40 @@ using ::powf; #ifndef __sun__ #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) _NOEXCEPT {return powf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} #endif template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -pow(_A1 __x, _A2 __y) _NOEXCEPT +pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return pow((__result_type)__x, (__result_type)__y); + return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); } - // sin using ::sin; using ::sinf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) _NOEXCEPT {return sinf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -sin(_A1 __x) _NOEXCEPT {return sin((double)__x);} +sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);} // sinh @@ -988,14 +987,14 @@ using ::sinh; using ::sinhf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) _NOEXCEPT {return sinhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -sinh(_A1 __x) _NOEXCEPT {return sinh((double)__x);} +sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);} // sqrt @@ -1005,14 +1004,14 @@ using ::sqrtf; #if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) _NOEXCEPT {return sqrtf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -sqrt(_A1 __x) _NOEXCEPT {return sqrt((double)__x);} +sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} // tan @@ -1021,14 +1020,14 @@ using ::tanf; #ifndef __sun__ #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) _NOEXCEPT {return tanf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -tan(_A1 __x) _NOEXCEPT {return tan((double)__x);} +tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);} // tanh @@ -1036,14 +1035,14 @@ using ::tanh; using ::tanhf; #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) _NOEXCEPT {return tanhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} #endif template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -tanh(_A1 __x) _NOEXCEPT {return tanh((double)__x);} +tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);} // acosh @@ -1051,13 +1050,13 @@ tanh(_A1 __x) _NOEXCEPT {return tanh((double)__x);} using ::acosh; using ::acoshf; -inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) _NOEXCEPT {return acoshf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) _NOEXCEPT {return acoshl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -acosh(_A1 __x) _NOEXCEPT {return acosh((double)__x);} +acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);} #endif // asinh @@ -1066,13 +1065,13 @@ acosh(_A1 __x) _NOEXCEPT {return acosh((double)__x);} using ::asinh; using ::asinhf; -inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) _NOEXCEPT {return asinhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) _NOEXCEPT {return asinhl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -asinh(_A1 __x) _NOEXCEPT {return asinh((double)__x);} +asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);} #endif // atanh @@ -1081,13 +1080,13 @@ asinh(_A1 __x) _NOEXCEPT {return asinh((double)__x);} using ::atanh; using ::atanhf; -inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) _NOEXCEPT {return atanhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) _NOEXCEPT {return atanhl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -atanh(_A1 __x) _NOEXCEPT {return atanh((double)__x);} +atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);} #endif // cbrt @@ -1096,13 +1095,13 @@ atanh(_A1 __x) _NOEXCEPT {return atanh((double)__x);} using ::cbrt; using ::cbrtf; -inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) _NOEXCEPT {return cbrtf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) _NOEXCEPT {return cbrtl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -cbrt(_A1 __x) _NOEXCEPT {return cbrt((double)__x);} +cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} #endif // copysign @@ -1110,23 +1109,23 @@ cbrt(_A1 __x) _NOEXCEPT {return cbrt((double)__x);} using ::copysign; using ::copysignf; -inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) _NOEXCEPT {return copysignf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) _NOEXCEPT {return copysignl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return copysignf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return copysignl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -copysign(_A1 __x, _A2 __y) _NOEXCEPT +copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return copysign((__result_type)__x, (__result_type)__y); + return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); } #ifndef _LIBCPP_MSVCRT @@ -1136,105 +1135,101 @@ copysign(_A1 __x, _A2 __y) _NOEXCEPT using ::erf; using ::erff; -inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) _NOEXCEPT {return erff(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) _NOEXCEPT {return erfl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -erf(_A1 __x) _NOEXCEPT {return erf((double)__x);} +erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);} // erfc using ::erfc; using ::erfcf; -inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) _NOEXCEPT {return erfcf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) _NOEXCEPT {return erfcl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -erfc(_A1 __x) _NOEXCEPT {return erfc((double)__x);} +erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);} // exp2 using ::exp2; using ::exp2f; -inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) _NOEXCEPT {return exp2f(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) _NOEXCEPT {return exp2l(__x);} +inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -exp2(_A1 __x) _NOEXCEPT {return exp2((double)__x);} +exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);} // expm1 using ::expm1; using ::expm1f; -inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) _NOEXCEPT {return expm1f(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) _NOEXCEPT {return expm1l(__x);} +inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -expm1(_A1 __x) _NOEXCEPT {return expm1((double)__x);} +expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);} // fdim using ::fdim; using ::fdimf; -inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) _NOEXCEPT {return fdimf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) _NOEXCEPT {return fdiml(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -fdim(_A1 __x, _A2 __y) _NOEXCEPT +fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return fdim((__result_type)__x, (__result_type)__y); + return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // fma -inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) _NOEXCEPT {return (float)((double)__x*__y + __z);} -#ifndef FP_FAST_FMAF -#define FP_FAST_FMAF -#endif - +using ::fmaf; using ::fma; -inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) _NOEXCEPT {return fmaf(__x, __y, __z);} -inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) _NOEXCEPT {return fmal(__x, __y, __z);} +inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, - typename __promote<_A1, _A2, _A3>::type + __promote<_A1, _A2, _A3> >::type -fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT +fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT { typedef typename __promote<_A1, _A2, _A3>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value && is_same<_A3, __result_type>::value)), ""); - return fma((__result_type)__x, (__result_type)__y, (__result_type)__z); + return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); } // fmax @@ -1242,23 +1237,23 @@ fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT using ::fmax; using ::fmaxf; -inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) _NOEXCEPT {return fmaxf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) _NOEXCEPT {return fmaxl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -fmax(_A1 __x, _A2 __y) _NOEXCEPT +fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return fmax((__result_type)__x, (__result_type)__y); + return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // fmin @@ -1266,23 +1261,23 @@ fmax(_A1 __x, _A2 __y) _NOEXCEPT using ::fmin; using ::fminf; -inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) _NOEXCEPT {return fminf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) _NOEXCEPT {return fminl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -fmin(_A1 __x, _A2 __y) _NOEXCEPT +fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return fmin((__result_type)__x, (__result_type)__y); + return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // hypot @@ -1290,23 +1285,23 @@ fmin(_A1 __x, _A2 __y) _NOEXCEPT using ::hypot; using ::hypotf; -inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) _NOEXCEPT {return hypotf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) _NOEXCEPT {return hypotl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -hypot(_A1 __x, _A2 __y) _NOEXCEPT +hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return hypot((__result_type)__x, (__result_type)__y); + return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // ilogb @@ -1314,27 +1309,27 @@ hypot(_A1 __x, _A2 __y) _NOEXCEPT using ::ilogb; using ::ilogbf; -inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) _NOEXCEPT {return ilogbf(__x);} -inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) _NOEXCEPT {return ilogbl(__x);} +inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, int>::type -ilogb(_A1 __x) _NOEXCEPT {return ilogb((double)__x);} +ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);} // lgamma using ::lgamma; using ::lgammaf; -inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) _NOEXCEPT {return lgammaf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) _NOEXCEPT {return lgammal(__x);} +inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -lgamma(_A1 __x) _NOEXCEPT {return lgamma((double)__x);} +lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);} // llrint @@ -1342,91 +1337,91 @@ lgamma(_A1 __x) _NOEXCEPT {return lgamma((double)__x);} using ::llrint; using ::llrintf; -inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) _NOEXCEPT {return llrintf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) _NOEXCEPT {return llrintl(__x);} +inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, long long>::type -llrint(_A1 __x) _NOEXCEPT {return llrint((double)__x);} +llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);} // llround using ::llround; using ::llroundf; -inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) _NOEXCEPT {return llroundf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) _NOEXCEPT {return llroundl(__x);} +inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, long long>::type -llround(_A1 __x) _NOEXCEPT {return llround((double)__x);} +llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);} // log1p using ::log1p; using ::log1pf; -inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) _NOEXCEPT {return log1pf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) _NOEXCEPT {return log1pl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -log1p(_A1 __x) _NOEXCEPT {return log1p((double)__x);} +log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);} // log2 using ::log2; using ::log2f; -inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) _NOEXCEPT {return log2f(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) _NOEXCEPT {return log2l(__x);} +inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -log2(_A1 __x) _NOEXCEPT {return log2((double)__x);} +log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);} // logb using ::logb; using ::logbf; -inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) _NOEXCEPT {return logbf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) _NOEXCEPT {return logbl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -logb(_A1 __x) _NOEXCEPT {return logb((double)__x);} +logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);} // lrint using ::lrint; using ::lrintf; -inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) _NOEXCEPT {return lrintf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) _NOEXCEPT {return lrintl(__x);} +inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, long>::type -lrint(_A1 __x) _NOEXCEPT {return lrint((double)__x);} +lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);} // lround using ::lround; using ::lroundf; -inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) _NOEXCEPT {return lroundf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) _NOEXCEPT {return lroundl(__x);} +inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, long>::type -lround(_A1 __x) _NOEXCEPT {return lround((double)__x);} +lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);} #endif // _LIBCPP_MSVCRT #endif // __sun__ @@ -1446,36 +1441,36 @@ using ::nanf; using ::nearbyint; using ::nearbyintf; -inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) _NOEXCEPT {return nearbyintf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) _NOEXCEPT {return nearbyintl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -nearbyint(_A1 __x) _NOEXCEPT {return nearbyint((double)__x);} +nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);} // nextafter using ::nextafter; using ::nextafterf; -inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) _NOEXCEPT {return nextafterf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) _NOEXCEPT {return nextafterl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -nextafter(_A1 __x, _A2 __y) _NOEXCEPT +nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return nextafter((__result_type)__x, (__result_type)__y); + return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // nexttoward @@ -1483,36 +1478,36 @@ nextafter(_A1 __x, _A2 __y) _NOEXCEPT using ::nexttoward; using ::nexttowardf; -inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) _NOEXCEPT {return nexttowardf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) _NOEXCEPT {return nexttowardl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -nexttoward(_A1 __x, long double __y) _NOEXCEPT {return nexttoward((double)__x, __y);} +nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);} // remainder using ::remainder; using ::remainderf; -inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) _NOEXCEPT {return remainderf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) _NOEXCEPT {return remainderl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -remainder(_A1 __x, _A2 __y) _NOEXCEPT +remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return remainder((__result_type)__x, (__result_type)__y); + return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); } // remquo @@ -1520,23 +1515,23 @@ remainder(_A1 __x, _A2 __y) _NOEXCEPT using ::remquo; using ::remquof; -inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) _NOEXCEPT {return remquof(__x, __y, __z);} -inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return remquol(__x, __y, __z);} +inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + __promote<_A1, _A2> >::type -remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT +remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT { typedef typename __promote<_A1, _A2>::type __result_type; static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value)), ""); - return remquo((__result_type)__x, (__result_type)__y, __z); + return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); } // rint @@ -1544,78 +1539,78 @@ remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT using ::rint; using ::rintf; -inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) _NOEXCEPT {return rintf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) _NOEXCEPT {return rintl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -rint(_A1 __x) _NOEXCEPT {return rint((double)__x);} +rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);} // round using ::round; using ::roundf; -inline _LIBCPP_INLINE_VISIBILITY float round(float __x) _NOEXCEPT {return roundf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) _NOEXCEPT {return roundl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -round(_A1 __x) _NOEXCEPT {return round((double)__x);} +round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);} // scalbln using ::scalbln; using ::scalblnf; -inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) _NOEXCEPT {return scalblnf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) _NOEXCEPT {return scalblnl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -scalbln(_A1 __x, long __y) _NOEXCEPT {return scalbln((double)__x, __y);} +scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);} // scalbn using ::scalbn; using ::scalbnf; -inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) _NOEXCEPT {return scalbnf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) _NOEXCEPT {return scalbnl(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -scalbn(_A1 __x, int __y) _NOEXCEPT {return scalbn((double)__x, __y);} +scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);} // tgamma using ::tgamma; using ::tgammaf; -inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) _NOEXCEPT {return tgammaf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) _NOEXCEPT {return tgammal(__x);} +inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -tgamma(_A1 __x) _NOEXCEPT {return tgamma((double)__x);} +tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);} // trunc using ::trunc; using ::truncf; -inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) _NOEXCEPT {return truncf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) _NOEXCEPT {return truncl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -trunc(_A1 __x) _NOEXCEPT {return trunc((double)__x);} +trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} #endif // !_LIBCPP_MSVCRT diff --git a/contrib/libc++/include/condition_variable b/contrib/libc++/include/condition_variable index dc67266a9..1af2484ab 100644 --- a/contrib/libc++/include/condition_variable +++ b/contrib/libc++/include/condition_variable @@ -115,6 +115,8 @@ public: #pragma GCC system_header #endif +#ifndef _LIBCPP_HAS_NO_THREADS + _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS condition_variable_any @@ -253,4 +255,6 @@ void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_THREADS + #endif // _LIBCPP_CONDITION_VARIABLE diff --git a/contrib/libc++/include/cstddef b/contrib/libc++/include/cstddef index 7ef16ff2a..c3ca64a9c 100644 --- a/contrib/libc++/include/cstddef +++ b/contrib/libc++/include/cstddef @@ -35,12 +35,6 @@ Types: #include <__config> -#ifdef __GLIBC__ -#define __need_NULL -#define __need_ptrdiff_t -#define __need_size_t -#endif // __GLIBC__ - #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -52,7 +46,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::ptrdiff_t; using ::size_t; +#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) +// Re-use the compiler's max_align_t where possible. +using ::max_align_t; +#else typedef long double max_align_t; +#endif #ifdef _LIBCPP_HAS_NO_NULLPTR diff --git a/contrib/libc++/include/deque b/contrib/libc++/include/deque index f099000b1..5602d4a3f 100644 --- a/contrib/libc++/include/deque +++ b/contrib/libc++/include/deque @@ -1208,7 +1208,7 @@ public: deque() _NOEXCEPT_(is_nothrow_default_constructible::value) {} - _LIBCPP_INLINE_VISIBILITY deque(const allocator_type& __a) : __base(__a) {} + _LIBCPP_INLINE_VISIBILITY explicit deque(const allocator_type& __a) : __base(__a) {} explicit deque(size_type __n); #if _LIBCPP_STD_VER > 11 explicit deque(size_type __n, const _Allocator& __a); @@ -1588,7 +1588,7 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l, { iterator __i = __base::begin(); iterator __e = __base::end(); - for (; __f != __l && __i != __e; ++__f, ++__i) + for (; __f != __l && __i != __e; ++__f, (void) ++__i) *__i = *__f; if (__f != __l) __append(__f, __l); @@ -2160,7 +2160,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, if (__n > __de) { __m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de); - for (_BiIter __j = __m; __j != __l; ++__i, ++__j, ++__base::size()) + for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__base::size()) __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j); __n = __de; } @@ -2200,7 +2200,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l, if (__n > __back_capacity) __add_back_capacity(__n - __back_capacity); // __n <= __back_capacity - for (iterator __i = __base::end(); __f != __l; ++__i, ++__f, ++__base::size()) + for (iterator __i = __base::end(); __f != __l; ++__i, (void) ++__f, ++__base::size()) __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__f); } diff --git a/contrib/libc++/include/experimental/__config b/contrib/libc++/include/experimental/__config new file mode 100644 index 000000000..684a3b4d8 --- /dev/null +++ b/contrib/libc++/include/experimental/__config @@ -0,0 +1,24 @@ +// -*- C++ -*- +//===--------------------------- __config ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_CONFIG +#define _LIBCPP_EXPERIMENTAL_CONFIG + +#include <__config> + +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } } +#define _VSTD_EXPERIMENTAL std::experimental + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { +#define _LIBCPP_END_NAMESPACE_LFTS } } } +#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1 + +#endif diff --git a/contrib/libc++/include/experimental/dynarray b/contrib/libc++/include/experimental/dynarray index 7c5c9b3f1..0bc8dfe2c 100644 --- a/contrib/libc++/include/experimental/dynarray +++ b/contrib/libc++/include/experimental/dynarray @@ -38,18 +38,18 @@ class dynarray public: // construct/copy/destroy: explicit dynarray(size_type c); - template - dynarray(size_type c, const Alloc& alloc); dynarray(size_type c, const T& v); - template - dynarray(size_type c, const T& v, const Alloc& alloc); dynarray(const dynarray& d); - template - dynarray(const dynarray& d, const Alloc& alloc); dynarray(initializer_list); - template - dynarray(initializer_list, const Alloc& alloc); + template + dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc); + template + dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc); + template + dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc); + template + dynarray(allocator_arg_t, const Alloc& a, initializer_list, const Alloc& alloc); dynarray& operator=(const dynarray&) = delete; ~dynarray(); @@ -147,12 +147,12 @@ private: assert(!"dynarray::allocation"); #endif } - return static_cast (::operator new (sizeof(value_type) * count)); + return static_cast (_VSTD::__allocate (sizeof(value_type) * count)); } static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept { - ::operator delete (static_cast (__ptr)); + _VSTD::__deallocate (static_cast (__ptr)); } public: @@ -163,15 +163,15 @@ public: dynarray(initializer_list); // We're not implementing these right now. -// Waiting for the resolution of LWG issue #2235 +// Updated with the resolution of LWG issue #2255 // template -// dynarray(size_type __c, const _Alloc& __alloc); +// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c); // template -// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc); +// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v); // template -// dynarray(const dynarray& __d, const _Alloc& __alloc); +// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d); // template -// dynarray(initializer_list, const _Alloc& __alloc); +// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list); dynarray& operator=(const dynarray&) = delete; ~dynarray(); diff --git a/contrib/libc++/include/experimental/optional b/contrib/libc++/include/experimental/optional index 3848da872..a384882a1 100644 --- a/contrib/libc++/include/experimental/optional +++ b/contrib/libc++/include/experimental/optional @@ -16,131 +16,147 @@ // C++1y -#include - -namespace std { namespace experimental { - -// optional for object types -template -class optional -{ -public: - typedef T value_type; - - // constructors - constexpr optional() noexcept; - constexpr optional(nullopt_t) noexcept; - optional(const optional&); - optional(optional&&) noexcept(is_nothrow_move_constructible::value); - constexpr optional(const T&); - constexpr optional(T&&); - template constexpr explicit optional(in_place_t, Args&&...); - template - constexpr explicit optional(in_place_t, initializer_list, Args&&...); - - // destructor - ~optional(); - - // assignment - optional& operator=(nullopt_t) noexcept; - optional& operator=(const optional&); - optional& operator=(optional&&) - noexcept(is_nothrow_move_assignable::value && - is_nothrow_move_constructible::value); - template optional& operator=(U&&); - template void emplace(Args&&...); - template void emplace(initializer_list, Args&&...); - - // swap - void swap(optional&) - noexcept(is_nothrow_move_constructible::value && - noexcept(swap(declval(), declval()))); - - // observers - constexpr T const* operator->() const; - T* operator->(); - constexpr T const& operator*() const; - T& operator*(); - constexpr explicit operator bool() const noexcept; - constexpr T const& value() const; - T& value(); - template constexpr T value_or(U&&) const&; - template T value_or(U&&) &&; -}; - -// In-place construction -struct in_place_t{}; -constexpr in_place_t in_place{}; - -// Disengaged state indicator -struct nullopt_t{see below}; -constexpr nullopt_t nullopt(unspecified); - -// class bad_optional_access -class bad_optional_access - : public logic_error -{ -public: - explicit bad_optional_access(const string& what_arg); - explicit bad_optional_access(const char* what_arg); -}; - -// Relational operators -template constexpr bool operator==(const optional&, const optional&); -template constexpr bool operator< (const optional&, const optional&); - -// Comparison with nullopt -template constexpr bool operator==(const optional&, nullopt_t) noexcept; -template constexpr bool operator==(nullopt_t, const optional&) noexcept; -template constexpr bool operator<(const optional&, nullopt_t) noexcept; -template constexpr bool operator<(nullopt_t, const optional&) noexcept; - -// Comparison with T -template constexpr bool operator==(const optional&, const T&); -template constexpr bool operator==(const T&, const optional&); -template constexpr bool operator<(const optional&, const T&); -template constexpr bool operator<(const T&, const optional&); - -// Specialized algorithms -template void swap(optional&, optional&) noexcept(see below); -template constexpr optional::type> make_optional(T&&); - -// hash support -template struct hash; -template struct hash>; - -}} // std::experimental +namespace std { namespace experimental { inline namespace fundamentals_v1 { + + // 5.3, optional for object types + template class optional; + + // 5.4, In-place construction + struct in_place_t{}; + constexpr in_place_t in_place{}; + + // 5.5, No-value state indicator + struct nullopt_t{see below}; + constexpr nullopt_t nullopt(unspecified); + + // 5.6, Class bad_optional_access + class bad_optional_access; + + // 5.7, Relational operators + template + constexpr bool operator==(const optional&, const optional&); + template + constexpr bool operator!=(const optional&, const optional&); + template + constexpr bool operator<(const optional&, const optional&); + template + constexpr bool operator>(const optional&, const optional&); + template + constexpr bool operator<=(const optional&, const optional&); + template + constexpr bool operator>=(const optional&, const optional&); + + // 5.8, Comparison with nullopt + template constexpr bool operator==(const optional&, nullopt_t) noexcept; + template constexpr bool operator==(nullopt_t, const optional&) noexcept; + template constexpr bool operator!=(const optional&, nullopt_t) noexcept; + template constexpr bool operator!=(nullopt_t, const optional&) noexcept; + template constexpr bool operator<(const optional&, nullopt_t) noexcept; + template constexpr bool operator<(nullopt_t, const optional&) noexcept; + template constexpr bool operator<=(const optional&, nullopt_t) noexcept; + template constexpr bool operator<=(nullopt_t, const optional&) noexcept; + template constexpr bool operator>(const optional&, nullopt_t) noexcept; + template constexpr bool operator>(nullopt_t, const optional&) noexcept; + template constexpr bool operator>=(const optional&, nullopt_t) noexcept; + template constexpr bool operator>=(nullopt_t, const optional&) noexcept; + + // 5.9, Comparison with T + template constexpr bool operator==(const optional&, const T&); + template constexpr bool operator==(const T&, const optional&); + template constexpr bool operator!=(const optional&, const T&); + template constexpr bool operator!=(const T&, const optional&); + template constexpr bool operator<(const optional&, const T&); + template constexpr bool operator<(const T&, const optional&); + template constexpr bool operator<=(const optional&, const T&); + template constexpr bool operator<=(const T&, const optional&); + template constexpr bool operator>(const optional&, const T&); + template constexpr bool operator>(const T&, const optional&); + template constexpr bool operator>=(const optional&, const T&); + template constexpr bool operator>=(const T&, const optional&); + + // 5.10, Specialized algorithms + template void swap(optional&, optional&) noexcept(see below); + template constexpr optional make_optional(T&&); + + template + class optional + { + public: + typedef T value_type; + + // 5.3.1, Constructors + constexpr optional() noexcept; + constexpr optional(nullopt_t) noexcept; + optional(const optional&); + optional(optional&&) noexcept(see below); + constexpr optional(const T&); + constexpr optional(T&&); + template constexpr explicit optional(in_place_t, Args&&...); + template + constexpr explicit optional(in_place_t, initializer_list, Args&&...); + + // 5.3.2, Destructor + ~optional(); + + // 5.3.3, Assignment + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional&); + optional& operator=(optional&&) noexcept(see below); + template optional& operator=(U&&); + template void emplace(Args&&...); + template + void emplace(initializer_list, Args&&...); + + // 5.3.4, Swap + void swap(optional&) noexcept(see below); + + // 5.3.5, Observers + constexpr T const* operator ->() const; + constexpr T* operator ->(); + constexpr T const& operator *() const &; + constexpr T& operator *() &; + constexpr T&& operator *() &&; + constexpr const T&& operator *() const &&; + constexpr explicit operator bool() const noexcept; + constexpr T const& value() const &; + constexpr T& value() &; + constexpr T&& value() &&; + constexpr const T&& value() const &&; + template constexpr T value_or(U&&) const &; + template constexpr T value_or(U&&) &&; + + private: + T* val; // exposition only + }; + + } // namespace fundamentals_v1 + } // namespace experimental + + // 5.11, Hash support + template struct hash; + template struct hash>; + +} // namespace std */ -#include <__config> +#include #include #include -namespace std { namespace experimental { - +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL class _LIBCPP_EXCEPTION_ABI bad_optional_access - : public logic_error + : public std::logic_error { public: -#if _LIBCPP_STD_VER > 11 - _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg) - : logic_error(__arg) {} - _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg) - : logic_error(__arg) {} - _LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default; - _LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default; -#else -private: - bad_optional_access(const bad_optional_access&); - bad_optional_access& operator=(const bad_optional_access&); -public: -#endif // _LIBCPP_STD_VER > 11 - // Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y + bad_optional_access() : std::logic_error("Bad optional Access") {} + +// Get the key function ~bad_optional_access() into the dylib virtual ~bad_optional_access() _NOEXCEPT; }; -}} // std::experimental +_LIBCPP_END_NAMESPACE_EXPERIMENTAL + #if _LIBCPP_STD_VER > 11 @@ -148,20 +164,14 @@ public: #include #include #include <__functional_base> - #include <__undef_min_max> - -#ifdef _LIBCPP_DEBUG -# include <__debug> -#else -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif +#include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -namespace std { namespace experimental { inline namespace __library_fundamentals_v1 { +_LIBCPP_BEGIN_NAMESPACE_LFTS struct in_place_t {}; constexpr in_place_t in_place{}; @@ -507,7 +517,7 @@ public: constexpr value_type const& value() const { if (!this->__engaged_) - throw bad_optional_access("optional::value: not engaged"); + throw bad_optional_access(); return this->__val_; } @@ -515,7 +525,7 @@ public: value_type& value() { if (!this->__engaged_) - throw bad_optional_access("optional::value: not engaged"); + throw bad_optional_access(); return this->__val_; } @@ -560,6 +570,7 @@ private: } }; +// Comparisons between optionals template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -573,6 +584,15 @@ operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) return *__x == *__y; } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__x == __y); +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -583,9 +603,38 @@ operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) return false; if (!static_cast(__x)) return true; - return less<_Tp>{}(*__x, *__y); + return *__x < *__y; } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return __y < __x; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__y < __x); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__x < __y); +} + + +// Comparisons with nullopt template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -604,6 +653,24 @@ operator==(nullopt_t, const optional<_Tp>& __x) noexcept return !static_cast(__x); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return static_cast(__x); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return static_cast(__x); +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -622,6 +689,61 @@ operator<(nullopt_t, const optional<_Tp>& __x) noexcept return static_cast(__x); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return !static_cast(__x); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return true; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return static_cast(__x); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return false; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>&, nullopt_t) noexcept +{ + return true; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return !static_cast(__x); +} + +// Comparisons with T template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -640,6 +762,24 @@ operator==(const _Tp& __v, const optional<_Tp>& __x) return static_cast(__x) ? *__x == __v : false; } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast(__x) ? !(*__x == __v) : true; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast(__x) ? !(*__x == __v) : true; +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr @@ -658,6 +798,61 @@ operator<(const _Tp& __v, const optional<_Tp>& __x) return static_cast(__x) ? less<_Tp>{}(__v, *__x) : false; } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, const _Tp& __v) +{ + return !(__x > __v); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const _Tp& __v, const optional<_Tp>& __x) +{ + return !(__v > __x); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast(__x) ? __v < __x : false; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast(__x) ? __x < __v : true; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>& __x, const _Tp& __v) +{ + return !(__x < __v); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const _Tp& __v, const optional<_Tp>& __x) +{ + return !(__v < __x); +} + + template inline _LIBCPP_INLINE_VISIBILITY void @@ -675,7 +870,7 @@ make_optional(_Tp&& __v) return optional::type>(_VSTD::forward<_Tp>(__v)); } -}}} // namespace std::experimental::__library_fundamentals_v1 +_LIBCPP_END_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_STD @@ -696,4 +891,4 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 11 -#endif // _LIBCPP_ARRAY +#endif // _LIBCPP_OPTIONAL diff --git a/contrib/libc++/include/experimental/string_view b/contrib/libc++/include/experimental/string_view new file mode 100644 index 000000000..d423f3900 --- /dev/null +++ b/contrib/libc++/include/experimental/string_view @@ -0,0 +1,815 @@ +// -*- C++ -*- +//===------------------------ string_view ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_LFTS_STRING_VIEW +#define _LIBCPP_LFTS_STRING_VIEW + +/* +string_view synopsis + +namespace std { + namespace experimental { + inline namespace library_fundamentals_v1 { + + // 7.2, Class template basic_string_view + template> + class basic_string_view; + + // 7.9, basic_string_view non-member comparison functions + template + constexpr bool operator==(basic_string_view x, + basic_string_view y) noexcept; + template + constexpr bool operator!=(basic_string_view x, + basic_string_view y) noexcept; + template + constexpr bool operator< (basic_string_view x, + basic_string_view y) noexcept; + template + constexpr bool operator> (basic_string_view x, + basic_string_view y) noexcept; + template + constexpr bool operator<=(basic_string_view x, + basic_string_view y) noexcept; + template + constexpr bool operator>=(basic_string_view x, + basic_string_view y) noexcept; + // see below, sufficient additional overloads of comparison functions + + // 7.10, Inserters and extractors + template + basic_ostream& + operator<<(basic_ostream& os, + basic_string_view str); + + // basic_string_view typedef names + typedef basic_string_view string_view; + typedef basic_string_view u16string_view; + typedef basic_string_view u32string_view; + typedef basic_string_view wstring_view; + + template> + class basic_string_view { + public: + // types + typedef traits traits_type; + typedef charT value_type; + typedef charT* pointer; + typedef const charT* const_pointer; + typedef charT& reference; + typedef const charT& const_reference; + typedef implementation-defined const_iterator; + typedef const_iterator iterator; + typedef reverse_iterator const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + static constexpr size_type npos = size_type(-1); + + // 7.3, basic_string_view constructors and assignment operators + constexpr basic_string_view() noexcept; + constexpr basic_string_view(const basic_string_view&) noexcept = default; + basic_string_view& operator=(const basic_string_view&) noexcept = default; + template + basic_string_view(const basic_string& str) noexcept; + constexpr basic_string_view(const charT* str); + constexpr basic_string_view(const charT* str, size_type len); + + // 7.4, basic_string_view iterator support + constexpr const_iterator begin() const noexcept; + constexpr const_iterator end() const noexcept; + constexpr const_iterator cbegin() const noexcept; + constexpr const_iterator cend() const noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; + + // 7.5, basic_string_view capacity + constexpr size_type size() const noexcept; + constexpr size_type length() const noexcept; + constexpr size_type max_size() const noexcept; + constexpr bool empty() const noexcept; + + // 7.6, basic_string_view element access + constexpr const_reference operator[](size_type pos) const; + constexpr const_reference at(size_type pos) const; + constexpr const_reference front() const; + constexpr const_reference back() const; + constexpr const_pointer data() const noexcept; + + // 7.7, basic_string_view modifiers + constexpr void clear() noexcept; + constexpr void remove_prefix(size_type n); + constexpr void remove_suffix(size_type n); + constexpr void swap(basic_string_view& s) noexcept; + + // 7.8, basic_string_view string operations + template + explicit operator basic_string() const; + template> + basic_string to_string( + const Allocator& a = Allocator()) const; + + size_type copy(charT* s, size_type n, size_type pos = 0) const; + + constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; + constexpr int compare(basic_string_view s) const noexcept; + constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; + constexpr int compare(size_type pos1, size_type n1, + basic_string_view s, size_type pos2, size_type n2) const; + constexpr int compare(const charT* s) const; + constexpr int compare(size_type pos1, size_type n1, const charT* s) const; + constexpr int compare(size_type pos1, size_type n1, + const charT* s, size_type n2) const; + constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find(charT c, size_type pos = 0) const noexcept; + constexpr size_type find(const charT* s, size_type pos, size_type n) const; + constexpr size_type find(const charT* s, size_type pos = 0) const; + constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; + constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; + constexpr size_type rfind(const charT* s, size_type pos = npos) const; + constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; + constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; + constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; + constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; + constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; + constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; + + private: + const_pointer data_; // exposition only + size_type size_; // exposition only + }; + + } // namespace fundamentals_v1 + } // namespace experimental + + // 7.11, Hash support + template struct hash; + template <> struct hash; + template <> struct hash; + template <> struct hash; + template <> struct hash; + +} // namespace std + + +*/ + +#include + +#include +#include +#include +#include +#include + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + template > + class _LIBCPP_TYPE_VIS_ONLY basic_string_view { + public: + // types + typedef _Traits traits_type; + typedef _CharT value_type; + typedef const _CharT* pointer; + typedef const _CharT* const_pointer; + typedef const _CharT& reference; + typedef const _CharT& const_reference; + typedef const_pointer const_iterator; // See [string.view.iterators] + typedef const_iterator iterator; + typedef _VSTD::reverse_iterator const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); + + // [string.view.cons], construct/copy + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const basic_string_view&) _NOEXCEPT = default; + + _LIBCPP_INLINE_VISIBILITY + basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; + + template + _LIBCPP_INLINE_VISIBILITY + basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT + : __data (__str.data()), __size(__str.size()) {} + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const _CharT* __s, size_type __len) + : __data(__s), __size(__len) + { +// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr"); + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const _CharT* __s) + : __data(__s), __size(_Traits::length(__s)) {} + + // [string.view.iterators], iterators + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator begin() const _NOEXCEPT { return cbegin(); } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator end() const _NOEXCEPT { return cend(); } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator cbegin() const _NOEXCEPT { return __data; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator cend() const _NOEXCEPT { return __data + __size; } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } + + // [string.view.capacity], capacity + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type size() const _NOEXCEPT { return __size; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type length() const _NOEXCEPT { return __size; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits::max(); } + + _LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY + empty() const _NOEXCEPT { return __size == 0; } + + // [string.view.access], element access + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference operator[](size_type __pos) const { return __data[__pos]; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference at(size_type __pos) const + { + return __pos >= size() + ? throw out_of_range("string_view::at") + : __data[__pos]; +// if (__pos >= size()) +// throw out_of_range("string_view::at"); +// return __data[__pos]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference front() const + { + return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference back() const + { + return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_pointer data() const _NOEXCEPT { return __data; } + + // [string.view.modifiers], modifiers: + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + { + __data = nullptr; + __size = 0; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void remove_prefix(size_type __n) _NOEXCEPT + { + _LIBCPP_ASSERT(n <= size(), "remove_prefix() can't remove more than size()"); + __data += __n; + __size -= __n; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void remove_suffix(size_type __n) _NOEXCEPT + { + _LIBCPP_ASSERT(n <= size(), "remove_suffix() can't remove more than size()"); + __size -= __n; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void swap(basic_string_view& __other) _NOEXCEPT + { + const value_type *__p = __data; + __data = __other.__data; + __other.__data = __p; + + size_type __sz = __size; + __size = __other.__size; + __other.__size = __sz; +// _VSTD::swap( __data, __other.__data ); +// _VSTD::swap( __size, __other.__size ); + } + + // [string.view.ops], string operations: + template + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const + { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); } + + template > + _LIBCPP_INLINE_VISIBILITY + basic_string<_CharT, _Traits, _Allocator> + to_string( const _Allocator& __a = _Allocator()) const + { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); } + + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const + { + if ( __pos > size()) + throw out_of_range("string_view::copy"); + size_type __rlen = _VSTD::min( __n, size() - __pos ); + _VSTD::copy_n(begin() + __pos, __rlen, __s ); + return __rlen; + } + + _LIBCPP_CONSTEXPR + basic_string_view substr(size_type __pos = 0, size_type __n = npos) const + { +// if (__pos > size()) +// throw out_of_range("string_view::substr"); +// size_type __rlen = _VSTD::min( __n, size() - __pos ); +// return basic_string_view(data() + __pos, __rlen); + return __pos > size() + ? throw out_of_range("string_view::substr") + : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT + { + size_type __rlen = _VSTD::min( size(), __sv.size()); + int __retval = _Traits::compare(data(), __sv.data(), __rlen); + if ( __retval == 0 ) // first __rlen chars matched + __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); + return __retval; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const + { + return substr(__pos1, __n1).compare(__sv); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare( size_type __pos1, size_type __n1, + basic_string_view _sv, size_type __pos2, size_type __n2) const + { + return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(const _CharT* __s) const + { + return compare(basic_string_view(__s)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, const _CharT* __s) const + { + return substr(__pos1, __n1).compare(basic_string_view(__s)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const + { + return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); + } + + // find + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); + return _VSTD::__str_find + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT + { + return _VSTD::__str_find + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr"); + return _VSTD::__str_find + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(const _CharT* __s, size_type __pos = 0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr"); + return _VSTD::__str_find + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // rfind + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); + return _VSTD::__str_rfind + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT + { + return _VSTD::__str_rfind + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr"); + return _VSTD::__str_rfind + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr"); + return _VSTD::__str_rfind + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_first_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr"); + return _VSTD::__str_find_first_of + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT + { return find(__c, __pos); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr"); + return _VSTD::__str_find_first_of + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(const _CharT* __s, size_type __pos=0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr"); + return _VSTD::__str_find_first_of + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_last_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr"); + return _VSTD::__str_find_last_of + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT + { return rfind(__c, __pos); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr"); + return _VSTD::__str_find_last_of + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr"); + return _VSTD::__str_find_last_of + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_first_not_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + return _VSTD::__str_find_first_not_of + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT + { + return _VSTD::__str_find_first_not_of + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + return _VSTD::__str_find_first_not_of + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); + return _VSTD::__str_find_first_not_of + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_last_not_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + return _VSTD::__str_find_last_not_of + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT + { + return _VSTD::__str_find_last_not_of + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + return _VSTD::__str_find_last_not_of + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); + return _VSTD::__str_find_last_not_of + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + private: + const value_type* __data; + size_type __size; + }; + + + // [string.view.comparison] + // operator == + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(basic_string_view<_CharT, _Traits> __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + + // operator != + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + + // operator < + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + + // operator > + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + + // operator <= + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + + // operator >= + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(typename _VSTD::common_type >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + + // [string.view.io] + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) + { + return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size()); + } + + typedef basic_string_view string_view; + typedef basic_string_view u16string_view; + typedef basic_string_view u32string_view; + typedef basic_string_view wstring_view; + +_LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_BEGIN_NAMESPACE_STD + +// [string.view.hash] +// Shamelessly stolen from +template +struct _LIBCPP_TYPE_VIS_ONLY hash > + : public unary_function, size_t> +{ + size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT; +}; + +template +size_t +hash >::operator()( + const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT +{ + return __do_string_hash(__val.data(), __val.data() + __val.size()); +} + +#if _LIBCPP_STD_VER > 11 +template +__quoted_output_proxy<_CharT, const _CharT *, _Traits> +quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv, + _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_output_proxy<_CharT, const _CharT *, _Traits> + ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape ); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_LFTS_STRING_VIEW diff --git a/contrib/libc++/include/experimental/type_traits b/contrib/libc++/include/experimental/type_traits new file mode 100644 index 000000000..ab2c8cdf8 --- /dev/null +++ b/contrib/libc++/include/experimental/type_traits @@ -0,0 +1,423 @@ +// -*- C++ -*- +//===-------------------------- type_traits -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS +#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS + +/** + experimental/type_traits synopsis + +// C++1y +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.10.4.1, primary type categories + template constexpr bool is_void_v + = is_void::value; + template constexpr bool is_null_pointer_v + = is_null_pointer::value; + template constexpr bool is_integral_v + = is_integral::value; + template constexpr bool is_floating_point_v + = is_floating_point::value; + template constexpr bool is_array_v + = is_array::value; + template constexpr bool is_pointer_v + = is_pointer::value; + template constexpr bool is_lvalue_reference_v + = is_lvalue_reference::value; + template constexpr bool is_rvalue_reference_v + = is_rvalue_reference::value; + template constexpr bool is_member_object_pointer_v + = is_member_object_pointer::value; + template constexpr bool is_member_function_pointer_v + = is_member_function_pointer::value; + template constexpr bool is_enum_v + = is_enum::value; + template constexpr bool is_union_v + = is_union::value; + template constexpr bool is_class_v + = is_class::value; + template constexpr bool is_function_v + = is_function::value; + + // See C++14 20.10.4.2, composite type categories + template constexpr bool is_reference_v + = is_reference::value; + template constexpr bool is_arithmetic_v + = is_arithmetic::value; + template constexpr bool is_fundamental_v + = is_fundamental::value; + template constexpr bool is_object_v + = is_object::value; + template constexpr bool is_scalar_v + = is_scalar::value; + template constexpr bool is_compound_v + = is_compound::value; + template constexpr bool is_member_pointer_v + = is_member_pointer::value; + + // See C++14 20.10.4.3, type properties + template constexpr bool is_const_v + = is_const::value; + template constexpr bool is_volatile_v + = is_volatile::value; + template constexpr bool is_trivial_v + = is_trivial::value; + template constexpr bool is_trivially_copyable_v + = is_trivially_copyable::value; + template constexpr bool is_standard_layout_v + = is_standard_layout::value; + template constexpr bool is_pod_v + = is_pod::value; + template constexpr bool is_literal_type_v + = is_literal_type::value; + template constexpr bool is_empty_v + = is_empty::value; + template constexpr bool is_polymorphic_v + = is_polymorphic::value; + template constexpr bool is_abstract_v + = is_abstract::value; + template constexpr bool is_final_v + = is_final::value; + template constexpr bool is_signed_v + = is_signed::value; + template constexpr bool is_unsigned_v + = is_unsigned::value; + template constexpr bool is_constructible_v + = is_constructible::value; + template constexpr bool is_default_constructible_v + = is_default_constructible::value; + template constexpr bool is_copy_constructible_v + = is_copy_constructible::value; + template constexpr bool is_move_constructible_v + = is_move_constructible::value; + template constexpr bool is_assignable_v + = is_assignable::value; + template constexpr bool is_copy_assignable_v + = is_copy_assignable::value; + template constexpr bool is_move_assignable_v + = is_move_assignable::value; + template constexpr bool is_destructible_v + = is_destructible::value; + template constexpr bool is_trivially_constructible_v + = is_trivially_constructible::value; + template constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible::value; + template constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible::value; + template constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible::value; + template constexpr bool is_trivially_assignable_v + = is_trivially_assignable::value; + template constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable::value; + template constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable::value; + template constexpr bool is_trivially_destructible_v + = is_trivially_destructible::value; + template constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible::value; + template constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible::value; + template constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible::value; + template constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible::value; + template constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable::value; + template constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable::value; + template constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable::value; + template constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible::value; + template constexpr bool has_virtual_destructor_v + = has_virtual_destructor::value; + + // See C++14 20.10.5, type property queries + template constexpr size_t alignment_of_v + = alignment_of::value; + template constexpr size_t rank_v + = rank::value; + template constexpr size_t extent_v + = extent::value; + + // See C++14 20.10.6, type relations + template constexpr bool is_same_v + = is_same::value; + template constexpr bool is_base_of_v + = is_base_of::value; + template constexpr bool is_convertible_v + = is_convertible::value; + + // 3.3.2, Other type transformations + template class invocation_type; // not defined + template class invocation_type; + template class raw_invocation_type; // not defined + template class raw_invocation_type; + + template + using invocation_type_t = typename invocation_type::type; + template + using raw_invocation_type_t = typename raw_invocation_type::type; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include + +#if _LIBCPP_STD_VER > 11 + +#include + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if __has_feature(cxx_variable_templates) + +// C++14 20.10.4.1, primary type categories + +template _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; + +// C++14 20.10.4.2, composite type categories + +template _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; + +// C++14 20.10.4.3, type properties + +template _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; + +// C++14 20.10.5, type properties queries + +template _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; + +template _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; + +template _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Id>::value; + +// C++14 20.10.6, type relations + +template _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_Tp, _Up>::value; + +#endif /* __has_feature(cxx_variable_templates) */ + +// 3.3.2, Other type transformations +/* +template +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; + +template +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; + +template +class _LIBCPP_TYPE_VIS_ONLY invokation_type; + +template +class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; + +template +using invokation_type_t = typename invokation_type<_Tp>::type; + +template +using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; +*/ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */ diff --git a/contrib/libc++/include/experimental/utility b/contrib/libc++/include/experimental/utility new file mode 100644 index 000000000..84e461af0 --- /dev/null +++ b/contrib/libc++/include/experimental/utility @@ -0,0 +1,44 @@ +// -*- C++ -*- +//===-------------------------- utility ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UTILITY +#define _LIBCPP_EXPERIMENTAL_UTILITY + +/* + experimental/utility synopsis + +// C++1y + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + 3.1.2, erased-type placeholder + struct erased_type { }; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +# include + +# include + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + struct _LIBCPP_TYPE_VIS_ONLY erased_type { }; + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */ diff --git a/contrib/libc++/include/ext/__hash b/contrib/libc++/include/ext/__hash index c0523cce4..5675d5405 100644 --- a/contrib/libc++/include/ext/__hash +++ b/contrib/libc++/include/ext/__hash @@ -19,8 +19,7 @@ namespace __gnu_cxx { using namespace std; -template struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<_Tp> - { }; +template struct _LIBCPP_TYPE_VIS_ONLY hash { }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function @@ -41,6 +40,96 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash return __do_string_hash(__c, __c + strlen(__c)); } }; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(signed char __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned char __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(short __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned short __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(int __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned int __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(long __c) const _NOEXCEPT + { + return __c; + } +}; + +template <> struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned long __c) const _NOEXCEPT + { + return __c; + } +}; } #endif // _LIBCPP_EXT_HASH diff --git a/contrib/libc++/include/ext/hash_map b/contrib/libc++/include/ext/hash_map index 225b72baa..36cd595e0 100644 --- a/contrib/libc++/include/ext/hash_map +++ b/contrib/libc++/include/ext/hash_map @@ -430,9 +430,9 @@ public: typedef const value_type& reference; typedef typename __pointer_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind + rebind #else - rebind::other + rebind::other #endif pointer; diff --git a/contrib/libc++/include/forward_list b/contrib/libc++/include/forward_list index 398226b8d..651452f3f 100644 --- a/contrib/libc++/include/forward_list +++ b/contrib/libc++/include/forward_list @@ -188,7 +188,6 @@ template struct __forward_list_node; template struct __forward_begin_node { - typedef __forward_begin_node __self; typedef _NodePtr pointer; pointer __next_; @@ -197,16 +196,22 @@ struct __forward_begin_node }; template -struct __forward_list_node - : public __forward_begin_node - < - typename pointer_traits<_VoidPtr>::template +struct _LIBCPP_HIDDEN __begin_node_of +{ + typedef __forward_begin_node + < + typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__forward_list_node<_Tp, _VoidPtr> > + rebind<__forward_list_node<_Tp, _VoidPtr> > #else - rebind<__forward_list_node<_Tp, _VoidPtr> >::other + rebind<__forward_list_node<_Tp, _VoidPtr> >::other #endif - > + > type; +}; + +template +struct __forward_list_node + : public __begin_node_of<_Tp, _VoidPtr>::type { typedef _Tp value_type; @@ -357,9 +362,9 @@ protected: typedef _Tp value_type; typedef _Alloc allocator_type; - typedef typename allocator_traits::void_pointer void_pointer; - typedef __forward_list_node __node; - typedef typename __node::__self __begin_node; + typedef typename allocator_traits::void_pointer void_pointer; + typedef __forward_list_node __node; + typedef typename __begin_node_of::type __begin_node; typedef typename allocator_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind_alloc<__node> @@ -986,7 +991,7 @@ forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) iterator __i = before_begin(); iterator __j = _VSTD::next(__i); iterator __e = end(); - for (; __j != __e && __f != __l; ++__i, ++__j, ++__f) + for (; __j != __e && __f != __l; ++__i, (void) ++__j, ++__f) *__j = *__f; if (__j == __e) insert_after(__i, __f, __l); @@ -1196,7 +1201,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, try { #endif // _LIBCPP_NO_EXCEPTIONS - for (++__f; __f != __l; ++__f, __last = __last->__next_) + for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f); @@ -1416,6 +1421,7 @@ template void forward_list<_Tp, _Alloc>::remove(const value_type& __v) { + forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing iterator __e = end(); for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) { @@ -1424,7 +1430,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v) iterator __j = _VSTD::next(__i, 2); for (; __j != __e && *__j == __v; ++__j) ; - erase_after(__i, __j); + __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j); if (__j == __e) break; __i = __j; diff --git a/contrib/libc++/include/functional b/contrib/libc++/include/functional index 891ed460a..d14b46bb7 100644 --- a/contrib/libc++/include/functional +++ b/contrib/libc++/include/functional @@ -1421,7 +1421,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;} + static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;} template ::value && __invokable<_Fp&, _ArgTypes...>::value> @@ -1617,21 +1617,22 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _ if (__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; - if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) + typedef typename __alloc_traits::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind_alloc<_FF> +#else + rebind_alloc<_FF>::other +#endif + _Ap; + _Ap __a(__a0); + if (sizeof(_FF) <= sizeof(__buf_) && + is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) { __f_ = (__base*)&__buf_; - ::new (__f_) _FF(_VSTD::move(__f)); + ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a)); } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; - _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); @@ -1857,15 +1858,15 @@ inline _LIBCPP_INLINE_VISIBILITY typename __invoke_of<_Ti&, _Uj...>::type __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { - return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...); + return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); } template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename __lazy_enable_if < is_bind_expression<_Ti>::value, - typename __invoke_of<_Ti&, _Uj...>::type + __invoke_of<_Ti&, _Uj...> >::type __mu(_Ti& __ti, tuple<_Uj...>& __uj) { @@ -1892,7 +1893,7 @@ typename enable_if __mu(_Ti&, _Uj& __uj) { const size_t _Indx = is_placeholder<_Ti>::value - 1; - return _VSTD::forward::type>(get<_Indx>(__uj)); + return _VSTD::forward::type>(_VSTD::get<_Indx>(__uj)); } template @@ -2019,7 +2020,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) { - return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...); + return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); } template diff --git a/contrib/libc++/include/future b/contrib/libc++/include/future index 73d5456d7..6fe6f8da5 100644 --- a/contrib/libc++/include/future +++ b/contrib/libc++/include/future @@ -374,6 +374,10 @@ template struct uses_allocator, Alloc>; #pragma GCC system_header #endif +#ifdef _LIBCPP_HAS_NO_THREADS +#error is not supported on this single threaded system +#else // !_LIBCPP_HAS_NO_THREADS + _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc @@ -779,9 +783,12 @@ __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); - typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_); + typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A; + typedef allocator_traits<_A> _ATraits; + typedef pointer_traits _PTraits; + _A __a(__alloc_); this->~__assoc_state_alloc(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template @@ -802,9 +809,12 @@ template void __assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT { - typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_); + typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A; + typedef allocator_traits<_A> _ATraits; + typedef pointer_traits _PTraits; + _A __a(__alloc_); this->~__assoc_state_alloc(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template @@ -825,9 +835,12 @@ template void __assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT { - typename _Alloc::template rebind<__assoc_sub_state_alloc>::other __a(__alloc_); + typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _A; + typedef allocator_traits<_A> _ATraits; + typedef pointer_traits _PTraits; + _A __a(__alloc_); this->~__assoc_sub_state_alloc(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template @@ -1410,12 +1423,13 @@ template template promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0) { - typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp, _Alloc> >::other _A2; + typedef __assoc_state_alloc<_Rp, _Alloc> _State; + typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); - unique_ptr<__assoc_state_alloc<_Rp, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1)); - ::new(__hold.get()) __assoc_state_alloc<_Rp, _Alloc>(__a0); - __state_ = __hold.release(); + unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); + ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); + __state_ = _VSTD::addressof(*__hold.release()); } template @@ -1583,12 +1597,13 @@ template template promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0) { - typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp&, _Alloc> >::other _A2; + typedef __assoc_state_alloc<_Rp&, _Alloc> _State; + typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); - unique_ptr<__assoc_state_alloc<_Rp&, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1)); - ::new(__hold.get()) __assoc_state_alloc<_Rp&, _Alloc>(__a0); - __state_ = __hold.release(); + unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); + ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); + __state_ = _VSTD::addressof(*__hold.release()); } template @@ -1719,12 +1734,13 @@ public: template promise::promise(allocator_arg_t, const _Alloc& __a0) { - typedef typename _Alloc::template rebind<__assoc_sub_state_alloc<_Alloc> >::other _A2; + typedef __assoc_sub_state_alloc<_Alloc> _State; + typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); - unique_ptr<__assoc_sub_state_alloc<_Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1)); - ::new(__hold.get()) __assoc_sub_state_alloc<_Alloc>(__a0); - __state_ = __hold.release(); + unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); + ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); + __state_ = _VSTD::addressof(*__hold.release()); } template @@ -1804,10 +1820,12 @@ template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() { - typedef typename _Alloc::template rebind<__packaged_task_func>::other _Ap; + typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap; + typedef allocator_traits<_Ap> _ATraits; + typedef pointer_traits _PTraits; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template @@ -1872,7 +1890,7 @@ template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f) : __f_(nullptr) { - typedef typename remove_reference<_Fp>::type _FR; + typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { @@ -1896,8 +1914,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function( allocator_arg_t, const _Alloc& __a0, _Fp&& __f) : __f_(nullptr) { - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename remove_reference<_Fp>::type _FR; + typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { @@ -1906,18 +1923,13 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function( } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a)); - __f_ = __hold.release(); + ::new (static_cast(_VSTD::addressof(*__hold.get()))) + _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a)); + __f_ = _VSTD::addressof(*__hold.release()); } } @@ -2612,4 +2624,6 @@ future::share() _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_THREADS + #endif // _LIBCPP_FUTURE diff --git a/contrib/libc++/include/iomanip b/contrib/libc++/include/iomanip index e334c7de9..a5042c7df 100644 --- a/contrib/libc++/include/iomanip +++ b/contrib/libc++/include/iomanip @@ -519,15 +519,16 @@ std::basic_ostream<_CharT, _Traits> & __quoted_output ( basic_ostream<_CharT, _Traits> &__os, _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) { - __os << __delim; + _VSTD::basic_string<_CharT, _Traits> __str; + __str.push_back(__delim); for ( ; __first != __last; ++ __first ) { if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) - __os << __escape; - __os << *__first; + __str.push_back(__escape); + __str.push_back(*__first); } - __os << __delim; - return __os; + __str.push_back(__delim); + return __put_character_sequence(__os, __str.data(), __str.size()); } template diff --git a/contrib/libc++/include/ios b/contrib/libc++/include/ios index d95f18a5e..ff79998b0 100644 --- a/contrib/libc++/include/ios +++ b/contrib/libc++/include/ios @@ -216,7 +216,7 @@ storage-class-specifier const error_category& iostream_category() noexcept; #include <__locale> #include -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) #include // for __xindex_ #endif @@ -367,7 +367,7 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic __xindex_; #else static int __xindex_; diff --git a/contrib/libc++/include/istream b/contrib/libc++/include/istream index 14fa46605..168a4d063 100644 --- a/contrib/libc++/include/istream +++ b/contrib/libc++/include/istream @@ -82,6 +82,13 @@ public: pos_type tellg(); basic_istream& seekg(pos_type); basic_istream& seekg(off_type, ios_base::seekdir); +protected: + basic_istream(const basic_istream& rhs) = delete; + basic_istream(basic_istream&& rhs); + // 27.7.2.1.2 Assign/swap: + basic_istream& operator=(const basic_istream& rhs) = delete; + basic_istream& operator=(basic_istream&& rhs); + void swap(basic_istream& rhs); }; // 27.7.1.2.3 character extraction templates: @@ -184,13 +191,22 @@ protected: _LIBCPP_INLINE_VISIBILITY basic_istream(basic_istream&& __rhs); #endif - // 27.7.1.1.2 Assign/swap: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_istream& operator=(basic_istream&& __rhs); #endif void swap(basic_istream& __rhs); + +#if _LIBCPP_STD_VER > 11 +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS + basic_istream (const basic_istream& __rhs) = delete; + basic_istream& operator=(const basic_istream& __rhs) = delete; +#else + basic_istream (const basic_istream& __rhs); // not defined + basic_istream& operator=(const basic_istream& __rhs); // not defined +#endif +#endif public: // 27.7.1.1.3 Prefix/suffix: diff --git a/contrib/libc++/include/iterator b/contrib/libc++/include/iterator index 70a664d99..bcf142a6c 100644 --- a/contrib/libc++/include/iterator +++ b/contrib/libc++/include/iterator @@ -138,6 +138,8 @@ template reverse_iterator operator+(typename reverse_iterator::difference_type n, const reverse_iterator& x); +template reverse_iterator make_reverse_iterator(Iterator i); // C++14 + template class back_insert_iterator { @@ -322,11 +324,23 @@ template reverse_iterator rend(T (&array)[N]); // template auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 template auto crend(const C& c) -> decltype(std::rend(c)); // C++14 +// 24.8, container access: +template constexpr auto size(const C& c) -> decltype(c.size()); // C++17 +template constexpr size_t size(const T (&array)[N]) noexcept; // C++17 +template constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17 +template constexpr bool empty(const T (&array)[N]) noexcept; // C++17 +template constexpr bool empty(initializer_list il) noexcept; // C++17 +template constexpr auto data(C& c) -> decltype(c.data()); // C++17 +template constexpr auto data(const C& c) -> decltype(c.data()); // C++17 +template constexpr T* data(T (&array)[N]) noexcept; // C++17 +template constexpr const E* data(initializer_list il) noexcept; // C++17 + } // std */ #include <__config> +#include <__functional_base> #include #include #include @@ -335,11 +349,7 @@ template auto crend(const C& c) -> decltype(std::rend(c)); // #include #endif -#ifdef _LIBCPP_DEBUG -# include <__debug> -#else -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif +#include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -364,10 +374,10 @@ public: static const bool value = sizeof(__test<_Tp>(0)) == 1; }; -template struct ____iterator_traits {}; +template struct __iterator_traits_impl {}; template -struct ____iterator_traits<_Iter, true> +struct __iterator_traits_impl<_Iter, true> { typedef typename _Iter::difference_type difference_type; typedef typename _Iter::value_type value_type; @@ -380,7 +390,7 @@ template struct __iterator_traits {}; template struct __iterator_traits<_Iter, true> - : ____iterator_traits + : __iterator_traits_impl < _Iter, is_convertible::value || @@ -534,7 +544,7 @@ class _LIBCPP_TYPE_VIS_ONLY reverse_iterator typename iterator_traits<_Iter>::reference> { private: - mutable _Iter __t; + mutable _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break protected: _Iter current; public: @@ -548,8 +558,8 @@ public: template _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {} _LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {__t = current; return *--__t;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} + _LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;} + _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return _VSTD::addressof(operator*());} _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;} _LIBCPP_INLINE_VISIBILITY reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} @@ -632,6 +642,15 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i return reverse_iterator<_Iter>(__x.base() - __n); } +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) +{ + return reverse_iterator<_Iter>(__i); +} +#endif + template class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator : public iteratorpush_back(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -678,7 +697,7 @@ protected: public: typedef _Container container_type; - _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {} + _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_) {container->push_front(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -713,7 +732,7 @@ public: typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i) - : container(&__x), iter(__i) {} + : container(_VSTD::addressof(__x)), iter(__i) {} _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_) {iter = container->insert(iter, __value_); ++iter; return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1386,7 +1405,7 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp* begin(_Tp (&__array)[_Np]) { @@ -1394,7 +1413,7 @@ begin(_Tp (&__array)[_Np]) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp* end(_Tp (&__array)[_Np]) { @@ -1466,17 +1485,17 @@ reverse_iterator rend(initializer_list<_Ep> __il) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 auto cbegin(const _Cp& __c) -> decltype(begin(__c)) { - return _VSTD::begin(__c); + return begin(__c); } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 auto cend(const _Cp& __c) -> decltype(end(__c)) { - return _VSTD::end(__c); + return end(__c); } template @@ -1560,6 +1579,36 @@ end(const _Cp& __c) #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) +#if _LIBCPP_STD_VER > 14 +template +constexpr auto size(const _C& __c) -> decltype(__c.size()) { return __c.size(); } + +template +constexpr size_t size(const _Tp (&__array)[_N]) noexcept { return _N; } + +template +constexpr auto empty(const _C& __c) -> decltype(__c.empty()) { return __c.empty(); } + +template +constexpr bool empty(const _Tp (&__array)[_N]) noexcept { return false; } + +template +constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } + +template constexpr +auto data(_C& __c) -> decltype(__c.data()) { return __c.data(); } + +template constexpr +auto data(const _C& __c) -> decltype(__c.data()) { return __c.data(); } + +template +constexpr _Tp* data(_Tp (&__array)[_N]) noexcept { return __array; } + +template +constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } +#endif + + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ITERATOR diff --git a/contrib/libc++/include/limits b/contrib/libc++/include/limits index d917c577f..ce967ea1b 100644 --- a/contrib/libc++/include/limits +++ b/contrib/libc++/include/limits @@ -235,9 +235,9 @@ protected: static _LIBCPP_CONSTEXPR const bool is_iec559 = false; static _LIBCPP_CONSTEXPR const bool is_bounded = true; - static _LIBCPP_CONSTEXPR const bool is_modulo = true; + static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value; -#if __i386__ || __x86_64__ +#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) static _LIBCPP_CONSTEXPR const bool traps = true; #else static _LIBCPP_CONSTEXPR const bool traps = false; @@ -768,7 +768,7 @@ template template _LIBCPP_CONSTEXPR const int numeric_limits::digits10; template - const int numeric_limits::max_digits10; + _LIBCPP_CONSTEXPR const int numeric_limits::max_digits10; template _LIBCPP_CONSTEXPR const bool numeric_limits::is_signed; template diff --git a/contrib/libc++/include/list b/contrib/libc++/include/list index 7ccc778c9..13f8a53bf 100644 --- a/contrib/libc++/include/list +++ b/contrib/libc++/include/list @@ -179,11 +179,7 @@ template #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG -# include <__debug> -#else -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif +#include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -214,10 +210,13 @@ struct __list_node_base pointer __next_; _LIBCPP_INLINE_VISIBILITY - __list_node_base() - : __prev_(static_cast(pointer_traits<__base_pointer>::pointer_to(*this))), - __next_(static_cast(pointer_traits<__base_pointer>::pointer_to(*this))) - {} + __list_node_base() : __prev_(__self()), __next_(__self()) {} + + _LIBCPP_INLINE_VISIBILITY + pointer __self() + { + return static_cast(pointer_traits<__base_pointer>::pointer_to(*this)); + } }; template @@ -753,20 +752,14 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) swap(__sz(), __c.__sz()); swap(__end_, __c.__end_); if (__sz() == 0) - __end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)); + __end_.__next_ = __end_.__prev_ = __end_.__self(); else - __end_.__prev_->__next_ = __end_.__next_->__prev_ - = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)); + __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self(); if (__c.__sz() == 0) - __c.__end_.__next_ = __c.__end_.__prev_ - = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)); + __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self(); else - __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ - = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)); + __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self(); + #if _LIBCPP_DEBUG_LEVEL >= 2 __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); @@ -1059,7 +1052,9 @@ public: #endif // _LIBCPP_DEBUG_LEVEL >= 2 private: - static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l); + static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l); + void __link_nodes_at_front(__node_pointer __f, __node_pointer __l); + void __link_nodes_at_back (__node_pointer __f, __node_pointer __l); iterator __iterator(size_type __n); template static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp); @@ -1081,6 +1076,31 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p __l->__next_ = __p; } +// Link in nodes [__f, __l] at the front of the list +template +inline _LIBCPP_INLINE_VISIBILITY +void +list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l) +{ + __f->__prev_ = base::__end_.__self(); + __l->__next_ = base::__end_.__next_; + __l->__next_->__prev_ = __l; + base::__end_.__next_ = __f; +} + +// Link in nodes [__f, __l] at the front of the list +template +inline _LIBCPP_INLINE_VISIBILITY +void +list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l) +{ + __l->__next_ = base::__end_.__self(); + __f->__prev_ = base::__end_.__prev_; + __f->__prev_->__next_ = __f; + base::__end_.__prev_ = __l; +} + + template inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Alloc>::iterator @@ -1502,7 +1522,7 @@ list<_Tp, _Alloc>::push_front(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes(base::__end_.__next_, __hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1515,8 +1535,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1531,7 +1550,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes(base::__end_.__next_, __hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1544,8 +1563,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1561,7 +1579,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes(base::__end_.__next_, __hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1575,8 +1593,7 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get(), __hold.get()); ++base::__sz(); __hold.release(); } @@ -1826,8 +1843,7 @@ list<_Tp, _Alloc>::resize(size_type __n) throw; } #endif // _LIBCPP_NO_EXCEPTIONS - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_); + __link_nodes_at_back(__r.__ptr_, __e.__ptr_); base::__sz() += __ds; } } @@ -2038,16 +2054,18 @@ template void list<_Tp, _Alloc>::remove(const value_type& __x) { - for (iterator __i = begin(), __e = end(); __i != __e;) + list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing + for (const_iterator __i = begin(), __e = end(); __i != __e;) { if (*__i == __x) { - iterator __j = _VSTD::next(__i); + const_iterator __j = _VSTD::next(__i); for (; __j != __e && *__j == __x; ++__j) ; - __i = erase(__i, __j); + __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j); + __i = __j; if (__i != __e) - __i = _VSTD::next(__i); + ++__i; } else ++__i; @@ -2068,7 +2086,7 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred) ; __i = erase(__i, __j); if (__i != __e) - __i = _VSTD::next(__i); + ++__i; } else ++__i; diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale index cdfe120e7..0d0100204 100644 --- a/contrib/libc++/include/locale +++ b/contrib/libc++/include/locale @@ -193,9 +193,14 @@ template class messages_byname; #include #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include -#else // _LIBCPP_MSVCRT +#elif defined(_NEWLIB_VERSION) +// FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an +// include of once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html +// has had a chance to bake for a bit +#include +#elif !defined(__ANDROID__) #include -#endif // !_LIBCPP_MSVCRT +#endif #ifdef __APPLE__ #include @@ -229,7 +234,8 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; // OSX has nice foo_l() functions that let you turn off use of the global // locale. Linux, not so much. The following functions avoid the locale when // that's possible and otherwise do the wrong thing. FIXME. -#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) +#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \ + defined(_NEWLIB_VERSION) #ifdef _LIBCPP_LOCALE__L_EXTENSIONS decltype(MB_CUR_MAX_L(_VSTD::declval())) @@ -417,7 +423,7 @@ int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { // and failbit is set in __err. // Else an iterator pointing to the matching keyword is found. If more than // one keyword matches, an iterator to the first matching keyword is returned. -// If on exit __b == __e, eofbit is set in __err. If __case_senstive is false, +// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, // __ct is used to force to lower case before comparing characters. // Examples: // Keywords: "a", "abb" @@ -450,7 +456,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, size_t __n_does_match = 0; // but none of them definitely do // Initialize all statuses to __might_match, except for "" keywords are __does_match unsigned char* __st = __status; - for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st) + for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (!__ky->empty()) *__st = __might_match; @@ -476,7 +482,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, // If the keyword doesn't match this character, then change the keyword // to doesn't match __st = __status; - for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st) + for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (*__st == __might_match) { @@ -510,7 +516,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, if (__n_might_match + __n_does_match > 1) { __st = __status; - for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st) + for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (*__st == __does_match && __ky->size() != __indx+1) { @@ -525,7 +531,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, if (__b == __e) __err |= ios_base::eofbit; // Return the first matching result - for (__st = __status; __kb != __ke; ++__kb, ++__st) + for (__st = __status; __kb != __ke; ++__kb, (void) ++__st) if (*__st == __does_match) break; if (__kb == __ke) @@ -1180,11 +1186,11 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, break; } // Stage 3 - __a[sizeof(__a)-1] = 0; + __buf.resize(__a_end - __a); #ifdef _LIBCPP_LOCALE__L_EXTENSIONS - if (sscanf_l(__a, _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) + if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) #else - if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1) + if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1) #endif __err = ios_base::failbit; // EOF checked @@ -1851,7 +1857,7 @@ __get_up_to_n_digits(_InputIterator& __b, _InputIterator __e, return 0; } int __r = __ct.narrow(__c, 0) - '0'; - for (++__b, --__n; __b != __e && __n > 0; ++__b, --__n) + for (++__b, (void) --__n; __b != __e && __n > 0; ++__b, (void) --__n) { // get next digit __c = *__b; @@ -1871,7 +1877,7 @@ public: }; template -class _LIBCPP_TYPE_VIS __time_get_c_storage +class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage { protected: typedef basic_string<_CharT> string_type; @@ -2038,7 +2044,7 @@ template locale::id time_get<_CharT, _InputIterator>::id; -// time_get primatives +// time_get primitives template void @@ -2259,7 +2265,7 @@ time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e, __err |= ios_base::eofbit; } -// time_get end primatives +// time_get end primitives template _InputIterator @@ -2509,7 +2515,7 @@ protected: }; template -class _LIBCPP_TYPE_VIS __time_get_storage +class _LIBCPP_TYPE_VIS_ONLY __time_get_storage : public __time_get { protected: @@ -2964,6 +2970,8 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e) size_t __cur_cap = static_cast(__e-__b.get()) * sizeof(_Tp); size_t __new_cap = __cur_cap < numeric_limits::max() / 2 ? 2 * __cur_cap : numeric_limits::max(); + if (__new_cap == 0) + __new_cap = sizeof(_Tp); size_t __n_off = static_cast(__n - __b.get()); _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap); if (__t == 0) @@ -3673,14 +3681,14 @@ template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION) return -1; -#else // _WIN32 +#else // _WIN32 || __ANDROID__ catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); if (__cat != -1) __cat = static_cast((static_cast(__cat) >> 1)); return __cat; -#endif // _WIN32 +#endif // _WIN32 || __ANDROID__ } template @@ -3688,7 +3696,7 @@ typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION) return __dflt; #else // _WIN32 string __ndflt; @@ -3710,7 +3718,7 @@ template void messages<_CharT>::do_close(catalog __c) const { -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) if (__c != -1) __c <<= 1; nl_catd __cat = (nl_catd)__c; diff --git a/contrib/libc++/include/map b/contrib/libc++/include/map index 9779b70e2..5c3969acd 100644 --- a/contrib/libc++/include/map +++ b/contrib/libc++/include/map @@ -159,7 +159,7 @@ public: template const_iterator find(const K& x) const; // C++14 template - size_type count(const K& x) const; + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); @@ -353,7 +353,7 @@ public: template const_iterator find(const K& x) const; // C++14 template - size_type count(const K& x) const; + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); @@ -835,11 +835,18 @@ public: typedef _VSTD::reverse_iterator const_reverse_iterator; _LIBCPP_INLINE_VISIBILITY - explicit map(const key_compare& __comp = key_compare()) + map() _NOEXCEPT_( is_nothrow_default_constructible::value && is_nothrow_default_constructible::value && is_nothrow_copy_constructible::value) + : __tree_(__vc(key_compare())) {} + + _LIBCPP_INLINE_VISIBILITY + explicit map(const key_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -1097,6 +1104,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_unique(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} @@ -1568,11 +1581,18 @@ public: typedef _VSTD::reverse_iterator const_reverse_iterator; _LIBCPP_INLINE_VISIBILITY - explicit multimap(const key_compare& __comp = key_compare()) + multimap() _NOEXCEPT_( is_nothrow_default_constructible::value && is_nothrow_default_constructible::value && is_nothrow_copy_constructible::value) + : __tree_(__vc(key_compare())) {} + + _LIBCPP_INLINE_VISIBILITY + explicit multimap(const key_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -1820,6 +1840,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_multi(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index b382f70b0..662faa0a7 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -479,6 +479,8 @@ public: template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; + weak_ptr(weak_ptr&& r) noexcept; // C++14 + template weak_ptr(weak_ptr&& r) noexcept; // C++14 // destructor ~weak_ptr(); @@ -487,6 +489,8 @@ public: weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; + weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 + template weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 // modifiers void swap(weak_ptr& r) noexcept; @@ -606,7 +610,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include #endif -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) # include #endif @@ -1446,7 +1450,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits template _LIBCPP_INLINE_VISIBILITY static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) - {__construct(__has_construct(), + {__construct(__has_construct(), __a, __p, _VSTD::forward<_Args>(__args)...);} #else // _LIBCPP_HAS_NO_VARIADICS template @@ -1627,9 +1631,9 @@ public: _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT {return _VSTD::addressof(__x);} _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator::const_pointer = 0) - {return static_cast(::operator new(__n * sizeof(_Tp)));} + {return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));} _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT - {::operator delete((void*)__p);} + {_VSTD::__deallocate((void*)__p);} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {return size_type(~0) / sizeof(_Tp);} #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -1717,9 +1721,9 @@ public: _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT {return _VSTD::addressof(__x);} _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator::const_pointer = 0) - {return static_cast(::operator new(__n * sizeof(_Tp)));} + {return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));} _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT - {::operator delete((void*)__p);} + {_VSTD::__deallocate((void*)__p);} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {return size_type(~0) / sizeof(_Tp);} #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -2001,8 +2005,8 @@ public: tuple<_Args2...> __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) - : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), - __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + : __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), + __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) {} #endif // _LIBCPP_HAS_NO_VARIADICS @@ -2015,7 +2019,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) { using _VSTD::swap; swap(__first_, __x.__first_); @@ -2092,8 +2096,8 @@ public: tuple<_Args2...> __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) - : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), - __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), + __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) {} #endif // _LIBCPP_HAS_NO_VARIADICS @@ -2106,7 +2110,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) { using _VSTD::swap; swap(__second_, __x.__second_); @@ -2184,8 +2188,8 @@ public: tuple<_Args2...> __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) - : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), - __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) + : _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...), + __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...) {} @@ -2199,7 +2203,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) { using _VSTD::swap; swap(__first_, __x.__first_); @@ -2274,8 +2278,8 @@ public: tuple<_Args2...> __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) - : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), - _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), + _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) {} #endif // _LIBCPP_HAS_NO_VARIADICS @@ -2288,7 +2292,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) { } }; @@ -2371,7 +2375,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) {base::swap(__x);} }; @@ -2380,7 +2384,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && - __is_nothrow_swappable<_T1>::value) + __is_nothrow_swappable<_T2>::value) {__x.swap(__y);} // __same_or_less_cv_qualified @@ -2397,13 +2401,14 @@ template struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> : false_type {}; -template ::value && - !is_pointer<_Ptr1>::value> +template ::value || + is_same<_Ptr1, _Ptr2>::value || + __has_element_type<_Ptr1>::value> struct __same_or_less_cv_qualified : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; template -struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> +struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false> : false_type {}; // default_delete @@ -2666,23 +2671,21 @@ public: "unique_ptr constructed with null function pointer deleter"); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type - > - _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT + template + _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p, + typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT : __ptr_(__p) { static_assert(!is_pointer::value, "unique_ptr constructed with null function pointer deleter"); } - template ::value>::type - > + template _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< is_reference::value, deleter_type, - typename add_lvalue_reference::type>::type __d) + typename add_lvalue_reference::type>::type __d, + typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT : __ptr_(__p, __d) {} @@ -2693,10 +2696,10 @@ public: _NOEXCEPT : __ptr_(pointer(), __d) {} - template ::value>::type - > - _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference::type&& __d) + template + _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, + typename remove_reference::type&& __d, + typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT : __ptr_(__p, _VSTD::move(__d)) { @@ -2811,10 +2814,10 @@ public: } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type - > - _LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type + reset(_Pp __p) _NOEXCEPT { pointer __tmp = __ptr_.first(); __ptr_.first() = __p; @@ -3657,7 +3660,7 @@ template const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT { - return __t == typeid(_Dp) ? &__data_.first().second() : 0; + return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0; } #endif // _LIBCPP_NO_RTTI @@ -3674,9 +3677,13 @@ template void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { - typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); + typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _A; + typedef allocator_traits<_A> _ATraits; + typedef pointer_traits _PTraits; + + _A __a(__data_.second()); __data_.second().~_Alloc(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template @@ -3739,9 +3746,12 @@ template void __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { - typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); + typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _A; + typedef allocator_traits<_A> _ATraits; + typedef pointer_traits _PTraits; + _A __a(__data_.first()); __data_.first().~_Alloc(); - __a.deallocate(this, 1); + __a.deallocate(_PTraits::pointer_to(*this), 1); } template class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; @@ -3759,27 +3769,15 @@ private: public: _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; - template::value - >::type - > - explicit shared_ptr(_Yp* __p); - template::value - >::type - > - shared_ptr(_Yp* __p, _Dp __d); - template::value - >::type - > - shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); + template + explicit shared_ptr(_Yp* __p, + typename enable_if::value, __nat>::type = __nat()); + template + shared_ptr(_Yp* __p, _Dp __d, + typename enable_if::value, __nat>::type = __nat()); + template + shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, + typename enable_if::value, __nat>::type = __nat()); template shared_ptr(nullptr_t __p, _Dp __d); template shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); template shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; @@ -3797,59 +3795,52 @@ public: template explicit shared_ptr(const weak_ptr<_Yp>& __r, typename enable_if::value, __nat>::type= __nat()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template::value - >::type - > - shared_ptr(auto_ptr<_Yp>&& __r); + template + shared_ptr(auto_ptr<_Yp>&& __r, + typename enable_if::value, __nat>::type = __nat()); #else - template::value - >::type - > - shared_ptr(auto_ptr<_Yp> __r); + template + shared_ptr(auto_ptr<_Yp> __r, + typename enable_if::value, __nat>::type = __nat()); #endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value && - is_convertible::pointer, element_type*>::value - >::type - > - shared_ptr(unique_ptr<_Yp, _Dp>&&, - typename enable_if::value, __nat>::type = __nat()); - template ::value && - is_convertible::pointer, element_type*>::value - >::type - > - shared_ptr(unique_ptr<_Yp, _Dp>&&, - typename enable_if::value, __nat>::type = __nat()); + template + shared_ptr(unique_ptr<_Yp, _Dp>&&, + typename enable_if + < + !is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type = __nat()); + template + shared_ptr(unique_ptr<_Yp, _Dp>&&, + typename enable_if + < + is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type = __nat()); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value && - is_convertible::pointer, element_type*>::value - >::type - > shared_ptr(unique_ptr<_Yp, _Dp>, - typename enable_if::value, __nat>::type = __nat()); - template ::value && - is_convertible::pointer, element_type*>::value - >::type - > - shared_ptr(unique_ptr<_Yp, _Dp>, - typename enable_if::value, __nat>::type = __nat()); + template + shared_ptr(unique_ptr<_Yp, _Dp>, + typename enable_if + < + !is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type = __nat()); + template + shared_ptr(unique_ptr<_Yp, _Dp>, + typename enable_if + < + is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type = __nat()); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_ptr(); @@ -4039,8 +4030,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT } template -template -shared_ptr<_Tp>::shared_ptr(_Yp* __p) +template +shared_ptr<_Tp>::shared_ptr(_Yp* __p, + typename enable_if::value, __nat>::type) : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); @@ -4051,8 +4043,9 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p) } template -template -shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) +template +shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, + typename enable_if::value, __nat>::type) : __ptr_(__p) { #ifndef _LIBCPP_NO_EXCEPTIONS @@ -4094,8 +4087,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) } template -template -shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) +template +shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, + typename enable_if::value, __nat>::type) : __ptr_(__p) { #ifndef _LIBCPP_NO_EXCEPTIONS @@ -4103,12 +4097,13 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) { #endif // _LIBCPP_NO_EXCEPTIONS typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); - ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); - __cntrl_ = __hold2.release(); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__p, __d, __a); + __cntrl_ = _VSTD::addressof(*__hold2.release()); __enable_weak_this(__p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -4130,12 +4125,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) { #endif // _LIBCPP_NO_EXCEPTIONS typedef __shared_ptr_pointer _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); - ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); - __cntrl_ = __hold2.release(); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__p, __d, __a); + __cntrl_ = _VSTD::addressof(*__hold2.release()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4208,12 +4204,13 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -template +template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) +shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, #else -shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) +shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, #endif + typename enable_if::value, __nat>::type) : __ptr_(__r.get()) { typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; @@ -4223,13 +4220,19 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) } template -template +template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, #else shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, #endif - typename enable_if::value, __nat>::type) + typename enable_if + < + !is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type) : __ptr_(__r.get()) { typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; @@ -4239,13 +4242,19 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, } template -template +template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, #else shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, #endif - typename enable_if::value, __nat>::type) + typename enable_if + < + is_lvalue_reference<_Dp>::value && + !is_array<_Yp>::value && + is_convertible::pointer, element_type*>::value, + __nat + >::type) : __ptr_(__r.get()) { typedef __shared_ptr_pointer<_Yp*, @@ -4282,14 +4291,15 @@ shared_ptr<_Tp> shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) { typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); - ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); shared_ptr<_Tp> __r; __r.__ptr_ = __hold2.get()->get(); - __r.__cntrl_ = __hold2.release(); + __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); __r.__enable_weak_this(__r.__ptr_); return __r; } @@ -4373,14 +4383,15 @@ shared_ptr<_Tp> shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) { typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; typedef __allocator_destructor<_Alloc2> _D2; _Alloc2 __alloc2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); - ::new(__hold2.get()) _CntrlBlk(__a); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__a); shared_ptr<_Tp> __r; __r.__ptr_ = __hold2.get()->get(); - __r.__cntrl_ = __hold2.release(); + __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); __r.__enable_weak_this(__r.__ptr_); return __r; } @@ -4391,14 +4402,15 @@ shared_ptr<_Tp> shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) { typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; typedef __allocator_destructor<_Alloc2> _D2; _Alloc2 __alloc2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); - ::new(__hold2.get()) _CntrlBlk(__a, __a0); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__a, __a0); shared_ptr<_Tp> __r; __r.__ptr_ = __hold2.get()->get(); - __r.__cntrl_ = __hold2.release(); + __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); __r.__enable_weak_this(__r.__ptr_); return __r; } @@ -4409,14 +4421,15 @@ shared_ptr<_Tp> shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) { typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; typedef __allocator_destructor<_Alloc2> _D2; _Alloc2 __alloc2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); - ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__a, __a0, __a1); shared_ptr<_Tp> __r; __r.__ptr_ = __hold2.get()->get(); - __r.__cntrl_ = __hold2.release(); + __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); __r.__enable_weak_this(__r.__ptr_); return __r; } @@ -4427,14 +4440,15 @@ shared_ptr<_Tp> shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) { typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; - typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; typedef __allocator_destructor<_Alloc2> _D2; _Alloc2 __alloc2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); - ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); + ::new(static_cast(_VSTD::addressof(*__hold2.get()))) + _CntrlBlk(__a, __a0, __a1, __a2); shared_ptr<_Tp> __r; __r.__ptr_ = __hold2.get()->get(); - __r.__cntrl_ = __hold2.release(); + __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); __r.__enable_weak_this(__r.__ptr_); return __r; } @@ -5262,7 +5276,7 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) class _LIBCPP_TYPE_VIS __sp_mut { @@ -5388,7 +5402,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v return atomic_compare_exchange_weak(__p, __v, __w); } -#endif // __has_feature(cxx_atomic) +#endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) //enum class struct _LIBCPP_TYPE_VIS pointer_safety diff --git a/contrib/libc++/include/module.modulemap b/contrib/libc++/include/module.modulemap new file mode 100644 index 000000000..6aeb23f02 --- /dev/null +++ b/contrib/libc++/include/module.modulemap @@ -0,0 +1,472 @@ +module std [system] { + // FIXME: The standard does not require that each of these submodules + // re-exports its imported modules. We should provide an alternative form of + // export that issues a warning if a name from the submodule is used, and + // use that to provide a 'strict mode' for libc++. + module algorithm { + header "algorithm" + export initializer_list + export * + } + module array { + header "array" + export initializer_list + export * + } + module atomic { + header "atomic" + export * + requires cplusplus11 + } + module bitset { + header "bitset" + export string + export iosfwd + export * + } + // No submodule for cassert. It fundamentally needs repeated, textual inclusion. + module ccomplex { + header "ccomplex" + export complex + export * + } + module cctype { + header "cctype" + export * + } + module cerrno { + header "cerrno" +/* + export_macros ECONNREFUSED, EIO, ENODEV, ENOTEMPTY, ERANGE, + E2BIG, ECONNRESET, EISCONN, ENOENT, ENOTRECOVERABLE, EROFS, + EACCES, EDEADLK, EISDIR, ENOEXEC, ENOTSOCK, ESPIPE, + EADDRINUSE, EDESTADDRREQ, ELOOP, ENOLCK, ENOTSUP, ESRCH, + EADDRNOTAVAIL, EDOM, EMFILE, ENOLINK, ENOTTY, ETIME, + EAFNOSUPPORT, EEXIST, EMLINK, ENOMEM, ENXIO, ETIMEDOUT, + EAGAIN, EFAULT, EMSGSIZE, ENOMSG, EOPNOTSUPP, ETXTBSY, + EALREADY, EFBIG, ENAMETOOLONG, ENOPROTOOPT, EOVERFLOW, EWOULDBLOCK, + EBADF, EHOSTUNREACH, ENETDOWN, ENOSPC, EOWNERDEAD, EXDEV, + EBADMSG, EIDRM, ENETRESET, ENOSR, EPERM, errno, + EBUSY, EILSEQ, ENETUNREACH, ENOSTR, EPIPE, + ECANCELED, EINPROGRESS, ENFILE, ENOSYS, EPROTO, + ECHILD, EINTR, ENOBUFS, ENOTCONN, EPROTONOSUPPORT, + ECONNABORTED, EINVAL, ENODATA, ENOTDIR, EPROTOTYPE +*/ + export * + } + module cfenv { + header "cfenv" +/* + export_macros FE_ALL_EXCEPT, FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW, + FE_UNDERFLOW, FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD, + FE_DFL_ENV +*/ + export * + } + module cfloat { + header "cfloat" +/* + export_macros FLT_EVAL_METHOD, FLT_RADIX, FLT_ROUNDS, + FLT_DIG, FLT_EPSILON, FLT_MANT_DIG, + FLT_MAX, FLT_MAX_10_EXP, FLT_MAX_EXP, + FLT_MIN, FLT_MIN_10_EXP, FLT_MIN_EXP, + DBL_DIG, DBL_EPSILON, DBL_MANT_DIG, + DBL_MAX, DBL_MAX_10_EXP, DBL_MAX_EXP, + DBL_MIN, DBL_MIN_10_EXP, DBL_MIN_EXP, + LDBL_DIG, LDBL_EPSILON, LDBL_MANT_DIG, + LDBL_MAX, LDBL_MAX_10_EXP, LDBL_MAX_EXP, + LDBL_MIN, LDBL_MIN_10_EXP, LDBL_MIN_EXP +*/ + export * + } + module chrono { + header "chrono" + export * + } + module cinttypes { + header "cinttypes" + export cstdint +/* + export_macros + PRId8, PRId16, PRId32, PRId64, PRIdFAST8, PRIdFAST16, PRIdFAST32, PRIdFAST64, PRIdLEAST8, PRIdLEAST16, PRIdLEAST32, PRIdLEAST64, PRIdMAX, PRIdPTR, + PRIi8, PRIi16, PRIi32, PRIi64, PRIiFAST8, PRIiFAST16, PRIiFAST32, PRIiFAST64, PRIiLEAST8, PRIiLEAST16, PRIiLEAST32, PRIiLEAST64, PRIiMAX, PRIiPTR, + PRIo8, PRIo16, PRIo32, PRIo64, PRIoFAST8, PRIoFAST16, PRIoFAST32, PRIoFAST64, PRIoLEAST8, PRIoLEAST16, PRIoLEAST32, PRIoLEAST64, PRIoMAX, PRIoPTR, + PRIu8, PRIu16, PRIu32, PRIu64, PRIuFAST8, PRIuFAST16, PRIuFAST32, PRIuFAST64, PRIuLEAST8, PRIuLEAST16, PRIuLEAST32, PRIuLEAST64, PRIuMAX, PRIuPTR, + PRIx8, PRIx16, PRIx32, PRIx64, PRIxFAST8, PRIxFAST16, PRIxFAST32, PRIxFAST64, PRIxLEAST8, PRIxLEAST16, PRIxLEAST32, PRIxLEAST64, PRIxMAX, PRIxPTR, + PRIX8, PRIX16, PRIX32, PRIX64, PRIXFAST8, PRIXFAST16, PRIXFAST32, PRIXFAST64, PRIXLEAST8, PRIXLEAST16, PRIXLEAST32, PRIXLEAST64, PRIXMAX, PRIXPTR, + SCNd8, SCNd16, SCNd32, SCNd64, SCNdFAST8, SCNdFAST16, SCNdFAST32, SCNdFAST64, SCNdLEAST8, SCNdLEAST16, SCNdLEAST32, SCNdLEAST64, SCNdMAX, SCNdPTR, + SCNi8, SCNi16, SCNi32, SCNi64, SCNiFAST8, SCNiFAST16, SCNiFAST32, SCNiFAST64, SCNiLEAST8, SCNiLEAST16, SCNiLEAST32, SCNiLEAST64, SCNiMAX, SCNiPTR, + SCNo8, SCNo16, SCNo32, SCNo64, SCNoFAST8, SCNoFAST16, SCNoFAST32, SCNoFAST64, SCNoLEAST8, SCNoLEAST16, SCNoLEAST32, SCNoLEAST64, SCNoMAX, SCNoPTR, + SCNu8, SCNu16, SCNu32, SCNu64, SCNuFAST8, SCNuFAST16, SCNuFAST32, SCNuFAST64, SCNuLEAST8, SCNuLEAST16, SCNuLEAST32, SCNuLEAST64, SCNuMAX, SCNuPTR, + SCNx8, SCNx16, SCNx32, SCNx64, SCNxFAST8, SCNxFAST16, SCNxFAST32, SCNxFAST64, SCNxLEAST8, SCNxLEAST16, SCNxLEAST32, SCNxLEAST64, SCNxMAX, SCNxPTR, + SCNX8, SCNX16, SCNX32, SCNX64, SCNXFAST8, SCNXFAST16, SCNXFAST32, SCNXFAST64, SCNXLEAST8, SCNXLEAST16, SCNXLEAST32, SCNXLEAST64, SCNXMAX, SCNXPTR +*/ + export * + } + module ciso646 { + header "ciso646" + export * + } + module climits { + header "climits" +/* + export_macros CHAR_BIT, CHAR_MIN, CHAR_MAX, + SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, + SHRT_MIN, SHRT_MAX, USHRT_MAX, + INT_MIN, INT_MAX, UINT_MAX, + LONG_MIN, LONG_MAX, ULONG_MAX, + LLONG_MIN, LLONG_MAX, ULLONG_MAX, + MB_LEN_MAX +*/ + export * + } + module clocale { + header "clocale" +/* + export_macros LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, NULL +*/ + export * + } + module cmath { + header "cmath" +/* + export_macros FP_FAST_FMA, FP_FAST_FMAF, FP_FAST_FMAL, FP_ILOGBO, FP_ILOGBNAN, + FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, + HUGE_VAL, HUGE_VALF, HUGE_VALL, INFINITY, NAN, + MATH_ERRNO, MATH_ERREXCEPT, math_errhandling +*/ + export * + } + module codecvt { + header "codecvt" + export * + } + module complex { + header "complex" + export * + } + module condition_variable { + header "condition_variable" + export * + } + module csetjmp { + header "csetjmp" +/* + export_macros setjmp +*/ + export * + } + module csignal { + header "csignal" +/* + export_macros SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, + SIG_DFL, SIG_IGN, SIG_ERR +*/ + export * + } + module cstdarg { + header "cstdarg" +/* + export_macros va_arg, va_start, va_end, va_copy +*/ + export * + } + module cstdbool { + header "cstdbool" +/* + export_macros __bool_true_false_are_defined +*/ + export * + } + module cstddef { + header "cstddef" +/* + export_macros NULL, offsetof +*/ + export * + } + module cstdint { + header "cstdint" +/* + export_macros + INT_8_MIN, INT_8_MAX, UINT_8_MAX, INT_16_MIN, INT_16_MAX, UINT_16_MAX, + INT_32_MIN, INT_32_MAX, UINT_32_MAX, INT_64_MIN, INT_64_MAX, UINT_64_MAX, + INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX, INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX, + INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX, INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX, + INT_LEAST8_MIN, INT_LEAST8_MAX, UINT_LEAST8_MAX, INT_LEAST16_MIN, INT_LEAST16_MAX, UINT_LEAST16_MAX, + INT_LEAST32_MIN, INT_LEAST32_MAX, UINT_LEAST32_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX, + INT_MAX_MIN, INT_MAX_MAX, UINT_MAX_MAX, INT_PTR_MIN, INT_PTR_MAX, UINT_PTR_MAX, + PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX, + SIZE_MAX +*/ + export * + } + module cstdio { + header "cstdio" +/* + export_macros BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_tmpnam, NULL, + SEEK_CUR, SEEK_END, SEEK_SET, TMP_MAX, _IOFBF, _IOLBF, + stdin, stdout, stderr +*/ + export * + } + module cstdlib { + header "cstdlib" +/* + export_macros RAND_MAX +*/ + export * + } + module cstring { + header "cstring" +/* + export_macros NULL +*/ + export * + } + module ctgmath { + header "ctgmath" + export ccomplex + export cmath + export * + } + module ctime { + header "ctime" +/* + export_macros NULL, CLOCKS_PER_SEC +*/ + export * + } + module cwchar { + header "cwchar" +/* + export_macros NULL, WCHAR_MAX, WCHAR_MIN, WEOF +*/ + export * + } + module cwctype { + header "cwctype" +/* + export_macros WEOF +*/ + export * + } + module deque { + header "deque" + export initializer_list + export * + } + module exception { + header "exception" + export * + } + module forward_list { + header "forward_list" + export initializer_list + export * + } + module fstream { + header "fstream" + export * + } + module functional { + header "functional" + export * + } + module future { + header "future" + export * + } + module initializer_list { + header "initializer_list" + export * + } + module iomanip { + header "iomanip" + export * + } + module ios { + header "ios" + export iosfwd + export * + } + module iosfwd { + header "iosfwd" + export * + } + module iostream { + header "iostream" + export ios + export streambuf + export istream + export ostream + export * + } + module istream { + header "istream" + // FIXME: should re-export ios, streambuf? + export * + } + module iterator { + header "iterator" + export * + } + module limits { + header "limits" + export * + } + module list { + header "list" + export initializer_list + export * + } + module locale { + header "locale" + export * + } + module map { + header "map" + export initializer_list + export * + } + module memory { + header "memory" + export * + } + module mutex { + header "mutex" + export * + } + module new { + header "new" + export * + } + module numeric { + header "numeric" + export * + } + module ostream { + header "ostream" + // FIXME: should re-export ios, streambuf? + export * + } + module queue { + header "queue" + export initializer_list + export * + } + module random { + header "random" + export initializer_list + export * + } + module ratio { + header "ratio" + export * + } + module regex { + header "regex" + export initializer_list + export * + } + module scoped_allocator { + header "scoped_allocator" + export * + } + module set { + header "set" + export initializer_list + export * + } + module sstream { + header "sstream" + // FIXME: should re-export istream, ostream, ios, streambuf, string? + export * + } + module stack { + header "stack" + export initializer_list + export * + } + module stdexcept { + header "stdexcept" + export * + } + module streambuf { + header "streambuf" + export * + } + module string { + header "string" + export initializer_list + export * + } + module strstream { + header "strstream" + requires !cplusplus11 + } + module system_error { + header "system_error" + export * + } + module thread { + header "thread" + export * + } + module tuple { + header "tuple" + export * + } + module type_traits { + header "type_traits" + export * + } + module typeindex { + header "typeindex" + export * + } + module typeinfo { + header "typeinfo" + export * + } + module unordered_map { + header "unordered_map" + export initializer_list + export * + } + module unordered_set { + header "unordered_set" + export initializer_list + export * + } + module utility { + header "utility" + export initializer_list + export * + } + module valarray { + header "valarray" + export initializer_list + export * + } + module vector { + header "vector" + export initializer_list + export * + } + + // FIXME: These should be private. + module __bit_reference { header "__bit_reference" export * } + module __config { header "__config" export * } + module __debug { header "__debug" export * } + module __functional_base { header "__functional_base" export * } + module __hash_table { header "__hash_table" export * } + module __locale { header "__locale" export * } + module __mutex_base { header "__mutex_base" export * } + module __split_buffer { header "__split_buffer" export * } + module __sso_allocator { header "__sso_allocator" export * } + module __std_stream { header "__std_stream" export * } + module __tree { header "__tree" export * } + module __tuple { header "__tuple" export * } + module __undef_min_max { header "__undef_min_max" export * } +} diff --git a/contrib/libc++/include/mutex b/contrib/libc++/include/mutex index e0c02adb5..e2a0daa3e 100644 --- a/contrib/libc++/include/mutex +++ b/contrib/libc++/include/mutex @@ -178,6 +178,7 @@ template #ifndef _LIBCPP_HAS_NO_VARIADICS #include #endif +#include #include <__undef_min_max> @@ -187,6 +188,8 @@ template _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_THREADS + class _LIBCPP_TYPE_VIS recursive_mutex { pthread_mutex_t __m_; @@ -425,7 +428,9 @@ lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3) #endif // _LIBCPP_HAS_NO_VARIADICS -struct _LIBCPP_TYPE_VIS once_flag; +#endif // !_LIBCPP_HAS_NO_THREADS + +struct _LIBCPP_TYPE_VIS_ONLY once_flag; #ifndef _LIBCPP_HAS_NO_VARIADICS diff --git a/contrib/libc++/include/new b/contrib/libc++/include/new index ea4a4a01a..a710ed93f 100644 --- a/contrib/libc++/include/new +++ b/contrib/libc++/include/new @@ -147,4 +147,24 @@ inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _N inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {} inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {} +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) { +#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE + return ::operator new(__size); +#else + return __builtin_operator_new(__size); +#endif +} + +inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) { +#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE + ::operator delete(__ptr); +#else + __builtin_operator_delete(__ptr); +#endif +} + +_LIBCPP_END_NAMESPACE_STD + #endif // _LIBCPP_NEW diff --git a/contrib/libc++/include/numeric b/contrib/libc++/include/numeric index e520c8e0d..21c3781ab 100644 --- a/contrib/libc++/include/numeric +++ b/contrib/libc++/include/numeric @@ -91,7 +91,7 @@ inline _LIBCPP_INLINE_VISIBILITY _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) { - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, (void) ++__first2) __init = __init + *__first1 * *__first2; return __init; } @@ -102,7 +102,7 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2) { - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, (void) ++__first2) __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); return __init; } @@ -116,7 +116,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res { typename iterator_traits<_InputIterator>::value_type __t(*__first); *__result = __t; - for (++__first, ++__result; __first != __last; ++__first, ++__result) + for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { __t = __t + *__first; *__result = __t; @@ -135,7 +135,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res { typename iterator_traits<_InputIterator>::value_type __t(*__first); *__result = __t; - for (++__first, ++__result; __first != __last; ++__first, ++__result) + for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { __t = __binary_op(__t, *__first); *__result = __t; @@ -153,7 +153,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t1(*__first); *__result = __t1; - for (++__first, ++__result; __first != __last; ++__first, ++__result) + for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __t2 - __t1; @@ -173,7 +173,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t1(*__first); *__result = __t1; - for (++__first, ++__result; __first != __last; ++__first, ++__result) + for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __binary_op(__t2, __t1); @@ -188,7 +188,7 @@ inline _LIBCPP_INLINE_VISIBILITY void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) { - for (; __first != __last; ++__first, ++__value_) + for (; __first != __last; ++__first, (void) ++__value_) *__first = __value_; } diff --git a/contrib/libc++/include/ostream b/contrib/libc++/include/ostream index 041314acc..a7af2994b 100644 --- a/contrib/libc++/include/ostream +++ b/contrib/libc++/include/ostream @@ -67,6 +67,13 @@ public: pos_type tellp(); basic_ostream& seekp(pos_type); basic_ostream& seekp(off_type, ios_base::seekdir); +protected: + basic_ostream(const basic_ostream& rhs) = delete; + basic_ostream(basic_ostream&& rhs); + // 27.7.3.3 Assign/swap + basic_ostream& operator=(basic_ostream& rhs) = delete; + basic_ostream& operator=(const basic_ostream&& rhs); + void swap(basic_ostream& rhs); }; // 27.7.2.6.4 character inserters @@ -162,14 +169,19 @@ protected: #endif // 27.7.2.3 Assign/swap -#if _LIBCPP_STD_VER > 11 - basic_ostream& operator=(const basic_ostream&) = delete; -#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_ostream& operator=(basic_ostream&& __rhs); #endif void swap(basic_ostream& __rhs); + +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS + basic_ostream (const basic_ostream& __rhs) = delete; + basic_ostream& operator=(const basic_ostream& __rhs) = delete; +#else + basic_ostream (const basic_ostream& __rhs); // not defined + basic_ostream& operator=(const basic_ostream& __rhs); // not defined +#endif public: // 27.7.2.4 Prefix/suffix: @@ -729,7 +741,8 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n) template basic_ostream<_CharT, _Traits>& -operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) +__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, + const _CharT* __str, size_t __len) { #ifndef _LIBCPP_NO_EXCEPTIONS try @@ -740,11 +753,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { typedef ostreambuf_iterator<_CharT, _Traits> _Ip; if (__pad_and_output(_Ip(__os), - &__c, + __str, (__os.flags() & ios_base::adjustfield) == ios_base::left ? - &__c + 1 : - &__c, - &__c + 1, + __str + __len : + __str, + __str + __len, __os, __os.fill()).failed()) __os.setstate(ios_base::badbit | ios_base::failbit); @@ -759,6 +772,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) return __os; } + +template +basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) +{ + return _VSTD::__put_character_sequence(__os, &__c, 1); +} + template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) @@ -796,129 +817,28 @@ template basic_ostream& operator<<(basic_ostream& __os, char __c) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - if (__pad_and_output(_Ip(__os), - &__c, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - &__c + 1 : - &__c, - &__c + 1, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, &__c, 1); } template basic_ostream& operator<<(basic_ostream& __os, signed char __c) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - if (__pad_and_output(_Ip(__os), - (char*)&__c, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - (char*)&__c + 1 : - (char*)&__c, - (char*)&__c + 1, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, (char *) &__c, 1); } template basic_ostream& operator<<(basic_ostream& __os, unsigned char __c) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - if (__pad_and_output(_Ip(__os), - (char*)&__c, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - (char*)&__c + 1 : - (char*)&__c, - (char*)&__c + 1, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, (char *) &__c, 1); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream<_CharT, _Traits>::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator<_CharT, _Traits> _Ip; - size_t __len = _Traits::length(__str); - if (__pad_and_output(_Ip(__os), - __str, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - __str + __len : - __str, - __str + __len, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str)); } template @@ -971,99 +891,23 @@ template basic_ostream& operator<<(basic_ostream& __os, const char* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - size_t __len = _Traits::length(__str); - if (__pad_and_output(_Ip(__os), - __str, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - __str + __len : - __str, - __str + __len, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str)); } template basic_ostream& operator<<(basic_ostream& __os, const signed char* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - size_t __len = _Traits::length((const char*)__str); - if (__pad_and_output(_Ip(__os), - (const char*)__str, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - (const char*)__str + __len : - (const char*)__str, - (const char*)__str + __len, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + const char *__s = (const char *) __str; + return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s)); } template basic_ostream& operator<<(basic_ostream& __os, const unsigned char* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator _Ip; - size_t __len = _Traits::length((const char*)__str); - if (__pad_and_output(_Ip(__os), - (const char*)__str, - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - (const char*)__str + __len : - (const char*)__str, - (const char*)__str + __len, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + const char *__s = (const char *) __str; + return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s)); } template @@ -1233,33 +1077,7 @@ basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - typename basic_ostream<_CharT, _Traits>::sentry __s(__os); - if (__s) - { - typedef ostreambuf_iterator<_CharT, _Traits> _Ip; - size_t __len = __str.size(); - if (__pad_and_output(_Ip(__os), - __str.data(), - (__os.flags() & ios_base::adjustfield) == ios_base::left ? - __str.data() + __len : - __str.data(), - __str.data() + __len, - __os, - __os.fill()).failed()) - __os.setstate(ios_base::badbit | ios_base::failbit); - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __os.__set_badbit_and_consider_rethrow(); - } -#endif // _LIBCPP_NO_EXCEPTIONS - return __os; + return _VSTD::__put_character_sequence(__os, __str.data(), __str.size()); } template diff --git a/contrib/libc++/include/random b/contrib/libc++/include/random index c0db1abac..a8d21a224 100644 --- a/contrib/libc++/include/random +++ b/contrib/libc++/include/random @@ -3475,9 +3475,9 @@ typedef shuffle_order_engine knuth_b; class _LIBCPP_TYPE_VIS random_device { -#if !defined(_WIN32) +#if !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)) int __f_; -#endif // defined(_WIN32) +#endif // !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)) public: // types typedef unsigned result_type; @@ -4009,6 +4009,8 @@ binomial_distribution<_IntType>::param_type::param_type(result_type __t, double } } +// Reference: Kemp, C.D. (1986). `A modal method for generating binomial +// variables', Commun. Statist. - Theor. Meth. 15(3), 805-813. template template _IntType @@ -4035,7 +4037,8 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) if (__u < 0) return __rd - 1; } - --__rd; + if ( __rd != 0 ) + --__rd; ++__ru; if (__ru <= __pr.__t_) { diff --git a/contrib/libc++/include/regex b/contrib/libc++/include/regex index ffe39cf1c..690213a97 100644 --- a/contrib/libc++/include/regex +++ b/contrib/libc++/include/regex @@ -437,7 +437,7 @@ class match_results public: typedef sub_match value_type; typedef const value_type& const_reference; - typedef const_reference reference; + typedef value_type& reference; typedef /implementation-defined/ const_iterator; typedef const_iterator iterator; typedef typename iterator_traits::difference_type difference_type; @@ -546,6 +546,13 @@ template const basic_regex& e, regex_constants::match_flag_type flags = regex_constants::match_default); +template + bool + regex_match(const basic_string&& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14 + template bool regex_match(const charT* str, const basic_regex& e, @@ -594,6 +601,13 @@ template const basic_regex& e, regex_constants::match_flag_type flags = regex_constants::match_default); +template + bool + regex_search(const basic_string&& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14 + template OutputIterator @@ -655,6 +669,10 @@ public: regex_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, regex_constants::match_flag_type m = regex_constants::match_default); + regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, + const regex_type&& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default) = delete; // C++14 regex_iterator(const regex_iterator&); regex_iterator& operator=(const regex_iterator&); @@ -690,16 +708,29 @@ public: regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, int submatch = 0, + regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, const vector& submatches, regex_constants::match_flag_type m = regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, const vector& submatches, + regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, initializer_list submatches, regex_constants::match_flag_type m = regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, initializer_list submatches, + regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 template regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, const int (&submatches)[N], regex_constants::match_flag_type m = regex_constants::match_default); + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, const int (&submatches)[N], + regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14; regex_token_iterator(const regex_token_iterator&); regex_token_iterator& operator=(const regex_token_iterator&); @@ -1161,7 +1192,8 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, // lookup_classname -ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase); +regex_traits::char_class_type _LIBCPP_FUNC_VIS +__get_classname(const char* __s, bool __icase); template template @@ -2153,8 +2185,8 @@ class __bracket_expression vector > __ranges_; vector > __digraphs_; vector __equivalences_; - ctype_base::mask __mask_; - ctype_base::mask __neg_mask_; + typename regex_traits<_CharT>::char_class_type __mask_; + typename regex_traits<_CharT>::char_class_type __neg_mask_; bool __negate_; bool __icase_; bool __collate_; @@ -2250,10 +2282,10 @@ public: void __add_equivalence(const string_type& __s) {__equivalences_.push_back(__s);} _LIBCPP_INLINE_VISIBILITY - void __add_class(ctype_base::mask __mask) + void __add_class(typename regex_traits<_CharT>::char_class_type __mask) {__mask_ |= __mask;} _LIBCPP_INLINE_VISIBILITY - void __add_neg_class(ctype_base::mask __mask) + void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask) {__neg_mask_ |= __mask;} }; @@ -3310,10 +3342,14 @@ basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, _ForwardIterator __temp = _VSTD::next(__first); if (__temp != __last) { - if (*__first == '\\' && '1' <= *__temp && *__temp <= '9') - { - __push_back_ref(*__temp - '0'); - __first = ++__temp; + if (*__first == '\\') + { + int __val = __traits_.value(*__temp, 10); + if (__val >= 1 && __val <= 9) + { + __push_back_ref(__val); + __first = ++__temp; + } } } } @@ -4052,14 +4088,19 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c) { - if (__first != __last && '0' <= *__first && *__first <= '9') + if (__first != __last ) { - __c = *__first - '0'; - for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; - ++__first) + int __val = __traits_.value(*__first, 10); + if ( __val != -1 ) { - __c *= 10; - __c += *__first - '0'; + __c = __val; + for (++__first; + __first != __last && ( __val = __traits_.value(*__first, 10)) != -1; + ++__first) + { + __c *= 10; + __c += __val; + } } } return __first; @@ -4501,6 +4542,13 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(__sum)); ++__first; break; + case '0': + if (__str) + *__str = _CharT(0); + else + __push_char(_CharT(0)); + ++__first; + break; default: if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) { @@ -4878,7 +4926,7 @@ bool operator==(const basic_string::value_type, _ST, _SA>& __x, const sub_match<_BiIter>& __y) { - return __y.compare(__x.c_str()) == 0; + return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0; } template @@ -4896,7 +4944,7 @@ bool operator<(const basic_string::value_type, _ST, _SA>& __x, const sub_match<_BiIter>& __y) { - return __y.compare(__x.c_str()) > 0; + return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0; } template @@ -4931,7 +4979,7 @@ bool operator==(const sub_match<_BiIter>& __x, const basic_string::value_type, _ST, _SA>& __y) { - return __x.compare(__y.c_str()) == 0; + return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; } template @@ -4949,7 +4997,7 @@ bool operator<(const sub_match<_BiIter>& __x, const basic_string::value_type, _ST, _SA>& __y) { - return __x.compare(__y.c_str()) < 0; + return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0; } template @@ -5223,7 +5271,7 @@ private: public: _BidirectionalIterator __position_start_; typedef const value_type& const_reference; - typedef const_reference reference; + typedef value_type& reference; typedef typename __container_type::const_iterator const_iterator; typedef const_iterator iterator; typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; @@ -5934,6 +5982,15 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s, return __r; } +#if _LIBCPP_STD_VER > 11 +template +bool +regex_search(const basic_string<_Cp, _ST, _SA>&& __s, + match_results::const_iterator, _Ap>&, + const basic_regex<_Cp, _Tp>& __e, + regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; +#endif + // regex_match template @@ -5986,6 +6043,16 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags); } +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +bool +regex_match(const basic_string<_CharT, _ST, _SA>&& __s, + match_results::const_iterator, _Allocator>& __m, + const basic_regex<_CharT, _Traits>& __e, + regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; +#endif + template inline _LIBCPP_INLINE_VISIBILITY bool @@ -6031,7 +6098,14 @@ public: regex_iterator(); regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, - regex_constants::match_flag_type __m = regex_constants::match_default); + regex_constants::match_flag_type __m + = regex_constants::match_default); +#if _LIBCPP_STD_VER > 11 + regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, + const regex_type&& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default) = delete; +#endif bool operator==(const regex_iterator& __x) const; _LIBCPP_INLINE_VISIBILITY @@ -6147,16 +6221,38 @@ public: const regex_type& __re, int __submatch = 0, regex_constants::match_flag_type __m = regex_constants::match_default); +#if _LIBCPP_STD_VER > 11 + regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, + const regex_type&& __re, int __submatch = 0, + regex_constants::match_flag_type __m = + regex_constants::match_default) = delete; +#endif + regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, const vector& __submatches, regex_constants::match_flag_type __m = regex_constants::match_default); +#if _LIBCPP_STD_VER > 11 + regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, + const regex_type&& __re, const vector& __submatches, + regex_constants::match_flag_type __m = + regex_constants::match_default) = delete; +#endif + #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, initializer_list __submatches, regex_constants::match_flag_type __m = regex_constants::match_default); + +#if _LIBCPP_STD_VER > 11 + regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, + const regex_type&& __re, + initializer_list __submatches, + regex_constants::match_flag_type __m = + regex_constants::match_default) = delete; +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template regex_token_iterator(_BidirectionalIterator __a, @@ -6165,6 +6261,16 @@ public: const int (&__submatches)[_Np], regex_constants::match_flag_type __m = regex_constants::match_default); +#if _LIBCPP_STD_VER > 11 + template + regex_token_iterator(_BidirectionalIterator __a, + _BidirectionalIterator __b, + const regex_type&& __re, + const int (&__submatches)[_Np], + regex_constants::match_flag_type __m = + regex_constants::match_default) = delete; +#endif + regex_token_iterator(const regex_token_iterator&); regex_token_iterator& operator=(const regex_token_iterator&); @@ -6188,6 +6294,12 @@ public: private: void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); + void __establish_result () { + if (__subs_[_N_] == -1) + __result_ = &__position_->prefix(); + else + __result_ = &(*__position_)[__subs_[_N_]]; + } }; template @@ -6205,12 +6317,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: __init(_BidirectionalIterator __a, _BidirectionalIterator __b) { if (__position_ != _Position()) - { - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; - } + __establish_result (); else if (__subs_[_N_] == -1) { __suffix_.matched = true; @@ -6287,7 +6394,9 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: __subs_(__x.__subs_) { if (__x.__result_ == &__x.__suffix_) - __result_ == &__suffix_; + __result_ = &__suffix_; + else if ( __result_ != nullptr ) + __establish_result (); } template @@ -6299,12 +6408,15 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: { __position_ = __x.__position_; if (__x.__result_ == &__x.__suffix_) - __result_ == &__suffix_; + __result_ = &__suffix_; else __result_ = __x.__result_; __suffix_ = __x.__suffix_; _N_ = __x._N_; __subs_ = __x.__subs_; + + if ( __result_ != nullptr && __result_ != &__suffix_ ) + __establish_result(); } return *this; } @@ -6337,22 +6449,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() else if (_N_ + 1 < __subs_.size()) { ++_N_; - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; + __establish_result(); } else { _N_ = 0; ++__position_; if (__position_ != _Position()) - { - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; - } + __establish_result(); else { if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end() diff --git a/contrib/libc++/include/set b/contrib/libc++/include/set index a537c5fe3..22d794da5 100644 --- a/contrib/libc++/include/set +++ b/contrib/libc++/include/set @@ -425,14 +425,22 @@ public: typedef _VSTD::reverse_iterator const_reverse_iterator; _LIBCPP_INLINE_VISIBILITY - explicit set(const value_compare& __comp = value_compare()) + set() _NOEXCEPT_( is_nothrow_default_constructible::value && is_nothrow_default_constructible::value && is_nothrow_copy_constructible::value) + : __tree_(value_compare()) {} + + _LIBCPP_INLINE_VISIBILITY + explicit set(const value_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__comp) {} + _LIBCPP_INLINE_VISIBILITY - set(const value_compare& __comp, const allocator_type& __a) + explicit set(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {} template _LIBCPP_INLINE_VISIBILITY @@ -655,6 +663,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_unique(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} @@ -822,14 +836,22 @@ public: // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY - explicit multiset(const value_compare& __comp = value_compare()) + multiset() _NOEXCEPT_( is_nothrow_default_constructible::value && is_nothrow_default_constructible::value && is_nothrow_copy_constructible::value) + : __tree_(value_compare()) {} + + _LIBCPP_INLINE_VISIBILITY + explicit multiset(const value_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__comp) {} + _LIBCPP_INLINE_VISIBILITY - multiset(const value_compare& __comp, const allocator_type& __a) + explicit multiset(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {} template _LIBCPP_INLINE_VISIBILITY @@ -1050,6 +1072,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_multi(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) diff --git a/contrib/libc++/include/shared_mutex b/contrib/libc++/include/shared_mutex index 5b1f53aaf..9b7f0bf77 100644 --- a/contrib/libc++/include/shared_mutex +++ b/contrib/libc++/include/shared_mutex @@ -19,14 +19,14 @@ namespace std { -class shared_mutex +class shared_timed_mutex { public: - shared_mutex(); - ~shared_mutex(); + shared_timed_mutex(); + ~shared_timed_mutex(); - shared_mutex(const shared_mutex&) = delete; - shared_mutex& operator=(const shared_mutex&) = delete; + shared_timed_mutex(const shared_timed_mutex&) = delete; + shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; // Exclusive ownership void lock(); // blocking @@ -112,9 +112,13 @@ template #pragma GCC system_header #endif +#ifdef _LIBCPP_HAS_NO_THREADS +#error is not supported on this single threaded system +#else // !_LIBCPP_HAS_NO_THREADS + _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_TYPE_VIS shared_mutex +class _LIBCPP_TYPE_VIS shared_timed_mutex { mutex __mut_; condition_variable __gate1_; @@ -124,11 +128,11 @@ class _LIBCPP_TYPE_VIS shared_mutex static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1); static const unsigned __n_readers_ = ~__write_entered_; public: - shared_mutex(); - _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default; + shared_timed_mutex(); + _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default; - shared_mutex(const shared_mutex&) = delete; - shared_mutex& operator=(const shared_mutex&) = delete; + shared_timed_mutex(const shared_timed_mutex&) = delete; + shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; // Exclusive ownership void lock(); @@ -163,7 +167,7 @@ public: template bool -shared_mutex::try_lock_until( +shared_timed_mutex::try_lock_until( const chrono::time_point<_Clock, _Duration>& __abs_time) { unique_lock __lk(__mut_); @@ -198,7 +202,7 @@ shared_mutex::try_lock_until( template bool -shared_mutex::try_lock_shared_until( +shared_timed_mutex::try_lock_shared_until( const chrono::time_point<_Clock, _Duration>& __abs_time) { unique_lock __lk(__mut_); @@ -232,7 +236,7 @@ private: public: _LIBCPP_INLINE_VISIBILITY - shared_lock() noexcept + shared_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} @@ -244,7 +248,7 @@ public: {__m_->lock_shared();} _LIBCPP_INLINE_VISIBILITY - shared_lock(mutex_type& __m, defer_lock_t) noexcept + shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT : __m_(&__m), __owns_(false) {} @@ -288,7 +292,7 @@ public: shared_lock& operator=(shared_lock const&) = delete; _LIBCPP_INLINE_VISIBILITY - shared_lock(shared_lock&& __u) noexcept + shared_lock(shared_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) { @@ -297,7 +301,7 @@ public: } _LIBCPP_INLINE_VISIBILITY - shared_lock& operator=(shared_lock&& __u) noexcept + shared_lock& operator=(shared_lock&& __u) _NOEXCEPT { if (__owns_) __m_->unlock_shared(); @@ -320,14 +324,14 @@ public: // Setters _LIBCPP_INLINE_VISIBILITY - void swap(shared_lock& __u) noexcept + void swap(shared_lock& __u) _NOEXCEPT { _VSTD::swap(__m_, __u.__m_); _VSTD::swap(__owns_, __u.__owns_); } _LIBCPP_INLINE_VISIBILITY - mutex_type* release() noexcept + mutex_type* release() _NOEXCEPT { mutex_type* __m = __m_; __m_ = nullptr; @@ -337,13 +341,13 @@ public: // Getters _LIBCPP_INLINE_VISIBILITY - bool owns_lock() const noexcept {return __owns_;} + bool owns_lock() const _NOEXCEPT {return __owns_;} _LIBCPP_INLINE_VISIBILITY - explicit operator bool () const noexcept {return __owns_;} + explicit operator bool () const _NOEXCEPT {return __owns_;} _LIBCPP_INLINE_VISIBILITY - mutex_type* mutex() const noexcept {return __m_;} + mutex_type* mutex() const _NOEXCEPT {return __m_;} }; template @@ -409,11 +413,13 @@ shared_lock<_Mutex>::unlock() template inline _LIBCPP_INLINE_VISIBILITY void -swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept +swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT {__x.swap(__y);} _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_THREADS + #endif // _LIBCPP_STD_VER > 11 #endif // _LIBCPP_SHARED_MUTEX diff --git a/contrib/libc++/include/sstream b/contrib/libc++/include/sstream index f90d4464a..27ae78f9d 100644 --- a/contrib/libc++/include/sstream +++ b/contrib/libc++/include/sstream @@ -325,11 +325,16 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) __p = const_cast(__str_.data()); if (__binp != -1) this->setg(__p + __binp, __p + __ninp, __p + __einp); + else + this->setg(nullptr, nullptr, nullptr); if (__bout != -1) { this->setp(__p + __bout, __p + __eout); this->pbump(__nout); } + else + this->setp(nullptr, nullptr); + __hm_ = __hm == -1 ? nullptr : __p + __hm; __mode_ = __rhs.__mode_; __p = const_cast(__rhs.__str_.data()); diff --git a/contrib/libc++/include/stdexcept b/contrib/libc++/include/stdexcept index ef5de595f..f251806fb 100644 --- a/contrib/libc++/include/stdexcept +++ b/contrib/libc++/include/stdexcept @@ -50,6 +50,14 @@ public: #pragma GCC system_header #endif +#ifndef _LIBCPP___REFSTRING +_LIBCPP_BEGIN_NAMESPACE_STD +class _LIBCPP_HIDDEN __libcpp_refstring { + const char *__imp_ _LIBCPP_UNUSED; +}; +_LIBCPP_END_NAMESPACE_STD +#endif + namespace std // purposefully not using versioning namespace { @@ -57,7 +65,7 @@ class _LIBCPP_EXCEPTION_ABI logic_error : public exception { private: - void* __imp_; + _VSTD::__libcpp_refstring __imp_; public: explicit logic_error(const string&); explicit logic_error(const char*); @@ -74,7 +82,7 @@ class _LIBCPP_EXCEPTION_ABI runtime_error : public exception { private: - void* __imp_; + _VSTD::__libcpp_refstring __imp_; public: explicit runtime_error(const string&); explicit runtime_error(const char*); diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index e8bd69fca..fe42bbf1d 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -161,7 +161,7 @@ public: basic_string& operator+=(initializer_list); basic_string& append(const basic_string& str); - basic_string& append(const basic_string& str, size_type pos, size_type n); + basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 basic_string& append(const value_type* s, size_type n); basic_string& append(const value_type* s); basic_string& append(size_type n, value_type c); @@ -178,7 +178,7 @@ public: basic_string& assign(const basic_string& str); basic_string& assign(basic_string&& str); - basic_string& assign(const basic_string& str, size_type pos, size_type n); + basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 basic_string& assign(const value_type* s, size_type n); basic_string& assign(const value_type* s); basic_string& assign(size_type n, value_type c); @@ -189,7 +189,7 @@ public: basic_string& insert(size_type pos1, const basic_string& str); basic_string& insert(size_type pos1, const basic_string& str, size_type pos2, size_type n); - basic_string& insert(size_type pos, const value_type* s, size_type n); + basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 basic_string& insert(size_type pos, const value_type* s); basic_string& insert(size_type pos, size_type n, value_type c); iterator insert(const_iterator p, value_type c); @@ -204,7 +204,7 @@ public: basic_string& replace(size_type pos1, size_type n1, const basic_string& str); basic_string& replace(size_type pos1, size_type n1, const basic_string& str, - size_type pos2, size_type n2); + size_type pos2, size_type n2=npos); // C++14 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); basic_string& replace(size_type pos, size_type n1, const value_type* s); basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); @@ -261,7 +261,7 @@ public: int compare(const basic_string& str) const noexcept; int compare(size_type pos1, size_type n1, const basic_string& str) const; int compare(size_type pos1, size_type n1, const basic_string& str, - size_type pos2, size_type n2) const; + size_type pos2, size_type n2=npos) const; // C++14 int compare(const value_type* s) const noexcept; int compare(size_type pos1, size_type n1, const value_type* s) const; int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; @@ -453,6 +453,8 @@ basic_string operator "" s( const char32_t *str, size_t len ); // C++1 #include <__undef_min_max> +#include <__debug> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -507,14 +509,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits typedef streampos pos_type; typedef mbstate_t state_type; - _LIBCPP_INLINE_VISIBILITY - static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT + static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -524,20 +523,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(EOF);} }; @@ -634,51 +628,37 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits typedef streampos pos_type; typedef mbstate_t state_type; - _LIBCPP_INLINE_VISIBILITY - static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT + static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return (unsigned char)__c1 < (unsigned char)__c2;} - _LIBCPP_INLINE_VISIBILITY - static int compare(const char_type* __s1, const char_type* __s2, size_t __n) + static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) {return memcmp(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY - static size_t length(const char_type* __s) {return strlen(__s);} - _LIBCPP_INLINE_VISIBILITY - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) + static inline size_t length(const char_type* __s) {return strlen(__s);} + static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) {return (const char_type*)memchr(__s, to_int_type(__a), __n);} - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) + static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) {return (char_type*)memmove(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) + static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return (char_type*)memcpy(__s1, __s2, __n); } - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) + static inline char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)memset(__s, to_int_type(__a), __n);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type((unsigned char)__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(EOF);} }; @@ -693,52 +673,38 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits typedef streampos pos_type; typedef mbstate_t state_type; - _LIBCPP_INLINE_VISIBILITY - static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT + static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} - _LIBCPP_INLINE_VISIBILITY - static int compare(const char_type* __s1, const char_type* __s2, size_t __n) + static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) {return wmemcmp(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY - static size_t length(const char_type* __s) + static inline size_t length(const char_type* __s) {return wcslen(__s);} - _LIBCPP_INLINE_VISIBILITY - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) + static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) {return (const char_type*)wmemchr(__s, __a, __n);} - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) + static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) {return (char_type*)wmemmove(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) + static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return (char_type*)wmemcpy(__s1, __s2, __n); } - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) + static inline char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)wmemset(__s, __a, __n);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(WEOF);} }; @@ -753,14 +719,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits typedef u16streampos pos_type; typedef mbstate_t state_type; - _LIBCPP_INLINE_VISIBILITY - static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT + static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -770,20 +733,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(0xDFFF);} }; @@ -874,14 +832,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits typedef u32streampos pos_type; typedef mbstate_t state_type; - _LIBCPP_INLINE_VISIBILITY - static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT + static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -891,20 +846,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT + static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(0xFFFFFFFF);} }; @@ -988,6 +938,191 @@ char_traits::assign(char_type* __s, size_t __n, char_type __a) #endif // _LIBCPP_HAS_NO_UNICODE_CHARS +// helper fns for basic_string + +// __str_find +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find(const _CharT *__p, _SizeT __sz, + _CharT __c, _SizeT __pos) _NOEXCEPT +{ + if (__pos >= __sz) + return __npos; + const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); + if (__r == 0) + return __npos; + return static_cast<_SizeT>(__r - __p); +} + +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT +{ + if (__pos > __sz || __sz - __pos < __n) + return __npos; + if (__n == 0) + return __pos; + const _CharT* __r = + _VSTD::__search(__p + __pos, __p + __sz, + __s, __s + __n, _Traits::eq, + random_access_iterator_tag(), random_access_iterator_tag()); + if (__r == __p + __sz) + return __npos; + return static_cast<_SizeT>(__r - __p); +} + + +// __str_rfind + +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_rfind(const _CharT *__p, _SizeT __sz, + _CharT __c, _SizeT __pos) _NOEXCEPT +{ + if (__sz < 1) + return __npos; + if (__pos < __sz) + ++__pos; + else + __pos = __sz; + for (const _CharT* __ps = __p + __pos; __ps != __p;) + { + if (_Traits::eq(*--__ps, __c)) + return static_cast<_SizeT>(__ps - __p); + } + return __npos; +} + +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_rfind(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT +{ + __pos = _VSTD::min(__pos, __sz); + if (__n < __sz - __pos) + __pos += __n; + else + __pos = __sz; + const _CharT* __r = _VSTD::__find_end( + __p, __p + __pos, __s, __s + __n, _Traits::eq, + random_access_iterator_tag(), random_access_iterator_tag()); + if (__n > 0 && __r == __p + __pos) + return __npos; + return static_cast<_SizeT>(__r - __p); +} + +// __str_find_first_of +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_first_of(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT +{ + if (__pos >= __sz || __n == 0) + return __npos; + const _CharT* __r = _VSTD::__find_first_of_ce + (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); + if (__r == __p + __sz) + return __npos; + return static_cast<_SizeT>(__r - __p); +} + + +// __str_find_last_of +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_last_of(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT + { + if (__n != 0) + { + if (__pos < __sz) + ++__pos; + else + __pos = __sz; + for (const _CharT* __ps = __p + __pos; __ps != __p;) + { + const _CharT* __r = _Traits::find(__s, __n, *--__ps); + if (__r) + return static_cast<_SizeT>(__ps - __p); + } + } + return __npos; +} + + +// __str_find_first_not_of +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_first_not_of(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT +{ + if (__pos < __sz) + { + const _CharT* __pe = __p + __sz; + for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) + if (_Traits::find(__s, __n, *__ps) == 0) + return static_cast<_SizeT>(__ps - __p); + } + return __npos; +} + + +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_first_not_of(const _CharT *__p, _SizeT __sz, + _CharT __c, _SizeT __pos) _NOEXCEPT +{ + if (__pos < __sz) + { + const _CharT* __pe = __p + __sz; + for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) + if (!_Traits::eq(*__ps, __c)) + return static_cast<_SizeT>(__ps - __p); + } + return __npos; +} + + +// __str_find_last_not_of +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_last_not_of(const _CharT *__p, _SizeT __sz, + const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT +{ + if (__pos < __sz) + ++__pos; + else + __pos = __sz; + for (const _CharT* __ps = __p + __pos; __ps != __p;) + if (_Traits::find(__s, __n, *--__ps) == 0) + return static_cast<_SizeT>(__ps - __p); + return __npos; +} + + +template +_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +__str_find_last_not_of(const _CharT *__p, _SizeT __sz, + _CharT __c, _SizeT __pos) _NOEXCEPT +{ + if (__pos < __sz) + ++__pos; + else + __pos = __sz; + for (const _CharT* __ps = __p + __pos; __ps != __p;) + if (!_Traits::eq(*--__ps, __c)) + return static_cast<_SizeT>(__ps - __p); + return __npos; +} + +template +size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) +{ + typedef typename iterator_traits<_Ptr>::value_type value_type; + return __murmur2_or_cityhash()(__p, (__e-__p)*sizeof(value_type)); +} + // basic_string template @@ -1324,7 +1459,7 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string& append(const basic_string& __str); - basic_string& append(const basic_string& __str, size_type __pos, size_type __n); + basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); basic_string& append(const value_type* __s, size_type __n); basic_string& append(const value_type* __s); basic_string& append(size_type __n, value_type __c); @@ -1363,7 +1498,7 @@ public: basic_string& assign(basic_string&& str) {*this = _VSTD::move(str); return *this;} #endif - basic_string& assign(const basic_string& __str, size_type __pos, size_type __n); + basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); basic_string& assign(const value_type* __s, size_type __n); basic_string& assign(const value_type* __s); basic_string& assign(size_type __n, value_type __c); @@ -1389,7 +1524,7 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string& insert(size_type __pos1, const basic_string& __str); - basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n); + basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); basic_string& insert(size_type __pos, const value_type* __s, size_type __n); basic_string& insert(size_type __pos, const value_type* __s); basic_string& insert(size_type __pos, size_type __n, value_type __c); @@ -1425,7 +1560,7 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); - basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2); + basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); @@ -1517,7 +1652,7 @@ public: int compare(const basic_string& __str) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; - int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const; + int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; int compare(const value_type* __s) const _NOEXCEPT; int compare(size_type __pos1, size_type __n1, const value_type* __s) const; int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; @@ -1951,11 +2086,13 @@ inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__a) { - if (__a == __str.__alloc() || !__str.__is_long()) - __r_.first().__r = __str.__r_.first().__r; - else + if (__str.__is_long() && __a != __str.__alloc()) // copy, not move __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); - __str.__zero(); + else + { + __r_.first().__r = __str.__r_.first().__r; + __str.__zero(); + } #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); if (__is_long()) @@ -2078,7 +2215,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For __set_long_cap(__cap+1); __set_long_size(__sz); } - for (; __first != __last; ++__first, ++__p) + for (; __first != __last; ++__first, (void) ++__p) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); } @@ -2209,7 +2346,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); size_type __cap = capacity(); if (__cap >= __n) { @@ -2383,7 +2520,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { - _LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); return assign(__s, traits_type::length(__s)); } @@ -2393,7 +2530,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) @@ -2530,7 +2667,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { - _LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); return append(__s, traits_type::length(__s)); } @@ -2540,7 +2677,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr"); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2692,7 +2829,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { - _LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); return insert(__pos, __s, traits_type::length(__s)); } @@ -2743,7 +2880,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) { - _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr"); + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2875,7 +3012,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { - _LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); } @@ -3243,18 +3380,9 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr"); - size_type __sz = size(); - if (__pos > __sz || __sz - __pos < __n) - return npos; - if (__n == 0) - return __pos; - const value_type* __p = data(); - const value_type* __r = _VSTD::search(__p + __pos, __p + __sz, __s, __s + __n, - __traits_eq()); - if (__r == __p + __sz) - return npos; - return static_cast(__r - __p); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); + return _VSTD::__str_find + (data(), size(), __s, __pos, __n); } template @@ -3263,7 +3391,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return find(__str.data(), __pos, __str.size()); + return _VSTD::__str_find + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3272,8 +3401,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr"); - return find(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); + return _VSTD::__str_find + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3281,14 +3411,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { - size_type __sz = size(); - if (__pos >= __sz) - return npos; - const value_type* __p = data(); - const value_type* __r = traits_type::find(__p + __pos, __sz - __pos, __c); - if (__r == 0) - return npos; - return static_cast(__r - __p); + return _VSTD::__str_find + (data(), size(), __c, __pos); } // rfind @@ -3299,19 +3423,9 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr"); - size_type __sz = size(); - __pos = _VSTD::min(__pos, __sz); - if (__n < __sz - __pos) - __pos += __n; - else - __pos = __sz; - const value_type* __p = data(); - const value_type* __r = _VSTD::find_end(__p, __p + __pos, __s, __s + __n, - __traits_eq()); - if (__n > 0 && __r == __p + __pos) - return npos; - return static_cast(__r - __p); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); + return _VSTD::__str_rfind + (data(), size(), __s, __pos, __n); } template @@ -3320,7 +3434,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return rfind(__str.data(), __pos, __str.size()); + return _VSTD::__str_rfind + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3329,8 +3444,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr"); - return rfind(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); + return _VSTD::__str_rfind + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3338,21 +3454,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { - size_type __sz = size(); - if (__sz) - { - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - const value_type* __p = data(); - for (const value_type* __ps = __p + __pos; __ps != __p;) - { - if (traits_type::eq(*--__ps, __c)) - return static_cast(__ps - __p); - } - } - return npos; + return _VSTD::__str_rfind + (data(), size(), __c, __pos); } // find_first_of @@ -3363,16 +3466,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr"); - size_type __sz = size(); - if (__pos >= __sz || __n == 0) - return npos; - const value_type* __p = data(); - const value_type* __r = _VSTD::find_first_of(__p + __pos, __p + __sz, __s, - __s + __n, __traits_eq()); - if (__r == __p + __sz) - return npos; - return static_cast(__r - __p); + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); + return _VSTD::__str_find_first_of + (data(), size(), __s, __pos, __n); } template @@ -3381,7 +3477,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return find_first_of(__str.data(), __pos, __str.size()); + return _VSTD::__str_find_first_of + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3390,8 +3487,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr"); - return find_first_of(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); + return _VSTD::__str_find_first_of + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3411,23 +3509,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr"); - if (__n != 0) - { - size_type __sz = size(); - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - const value_type* __p = data(); - for (const value_type* __ps = __p + __pos; __ps != __p;) - { - const value_type* __r = traits_type::find(__s, __n, *--__ps); - if (__r) - return static_cast(__ps - __p); - } - } - return npos; + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); + return _VSTD::__str_find_last_of + (data(), size(), __s, __pos, __n); } template @@ -3436,7 +3520,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return find_last_of(__str.data(), __pos, __str.size()); + return _VSTD::__str_find_last_of + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3445,8 +3530,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr"); - return find_last_of(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); + return _VSTD::__str_find_last_of + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3466,17 +3552,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr"); - size_type __sz = size(); - if (__pos < __sz) - { - const value_type* __p = data(); - const value_type* __pe = __p + __sz; - for (const value_type* __ps = __p + __pos; __ps != __pe; ++__ps) - if (traits_type::find(__s, __n, *__ps) == 0) - return static_cast(__ps - __p); - } - return npos; + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); + return _VSTD::__str_find_first_not_of + (data(), size(), __s, __pos, __n); } template @@ -3485,7 +3563,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return find_first_not_of(__str.data(), __pos, __str.size()); + return _VSTD::__str_find_first_not_of + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3494,8 +3573,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr"); - return find_first_not_of(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); + return _VSTD::__str_find_first_not_of + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3504,16 +3584,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - size_type __sz = size(); - if (__pos < __sz) - { - const value_type* __p = data(); - const value_type* __pe = __p + __sz; - for (const value_type* __ps = __p + __pos; __ps != __pe; ++__ps) - if (!traits_type::eq(*__ps, __c)) - return static_cast(__ps - __p); - } - return npos; + return _VSTD::__str_find_first_not_of + (data(), size(), __c, __pos); } // find_last_not_of @@ -3524,17 +3596,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr"); - size_type __sz = size(); - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - const value_type* __p = data(); - for (const value_type* __ps = __p + __pos; __ps != __p;) - if (traits_type::find(__s, __n, *--__ps) == 0) - return static_cast(__ps - __p); - return npos; + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); + return _VSTD::__str_find_last_not_of + (data(), size(), __s, __pos, __n); } template @@ -3543,7 +3607,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return find_last_not_of(__str.data(), __pos, __str.size()); + return _VSTD::__str_find_last_not_of + (data(), size(), __str.data(), __pos, __str.size()); } template @@ -3552,8 +3617,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr"); - return find_last_not_of(__s, __pos, traits_type::length(__s)); + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); + return _VSTD::__str_find_last_not_of + (data(), size(), __s, __pos, traits_type::length(__s)); } template @@ -3562,16 +3628,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - size_type __sz = size(); - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - const value_type* __p = data(); - for (const value_type* __ps = __p + __pos; __ps != __p;) - if (!traits_type::eq(*--__ps, __c)) - return static_cast(__ps - __p); - return npos; + return _VSTD::__str_find_last_not_of + (data(), size(), __c, __pos); } // compare @@ -3623,7 +3681,7 @@ template int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { - _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(0, npos, __s, traits_type::length(__s)); } @@ -3633,7 +3691,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { - _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); } @@ -3644,7 +3702,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, const value_type* __s, size_type __n2) const { - _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr"); + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) this->__throw_out_of_range(); @@ -4060,13 +4118,6 @@ template const typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::npos; -template -size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) -{ - typedef typename iterator_traits<_Ptr>::value_type value_type; - return __murmur2_or_cityhash()(__p, (__e-__p)*sizeof(value_type)); -} - template struct _LIBCPP_TYPE_VIS_ONLY hash > : public unary_function, size_t> diff --git a/contrib/libc++/include/thread b/contrib/libc++/include/thread index 1f1e4a2b9..8a30102f4 100644 --- a/contrib/libc++/include/thread +++ b/contrib/libc++/include/thread @@ -99,6 +99,7 @@ void sleep_for(const chrono::duration& rel_time); #include #endif #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -106,6 +107,10 @@ void sleep_for(const chrono::duration& rel_time); #define __STDCPP_THREADS__ __cplusplus +#ifdef _LIBCPP_HAS_NO_THREADS +#error is not supported on this single threaded system +#else // !_LIBCPP_HAS_NO_THREADS + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -455,4 +460,6 @@ void yield() _NOEXCEPT {sched_yield();} _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_THREADS + #endif // _LIBCPP_THREAD diff --git a/contrib/libc++/include/tuple b/contrib/libc++/include/tuple index a1a7bcf0b..5fc27f982 100644 --- a/contrib/libc++/include/tuple +++ b/contrib/libc++/include/tuple @@ -74,7 +74,7 @@ const unspecified ignore; template tuple make_tuple(T&&...); // constexpr in C++14 template tuple forward_as_tuple(T&&...) noexcept; // constexpr in C++14 -template tuple tie(T&...) noexcept; +template tuple tie(T&...) noexcept; // constexpr in C++14 template tuple tuple_cat(Tuples&&... tpls); // constexpr in C++14 // 20.4.1.4, tuple helper classes: @@ -82,13 +82,15 @@ template class tuple_size; // undefined template class tuple_size>; template class tuple_element; // undefined template class tuple_element>; +template + using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14 // 20.4.1.5, element access: template typename tuple_element>::type& get(tuple&) noexcept; // constexpr in C++14 template - typename tuple_element>::type const& + typename const tuple_element>::type & get(const tuple&) noexcept; // constexpr in C++14 template typename tuple_element>::type&& @@ -152,6 +154,11 @@ public: typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; }; +#if _LIBCPP_STD_VER > 11 +template +using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; +#endif + // __tuple_leaf template ::value @@ -203,7 +210,13 @@ public: "Attempted to default construct a reference element in a tuple");} template ::value>::type> + class = typename enable_if< + __lazy_and< + __lazy_not::type, __tuple_leaf>> + , is_constructible<_Hp, _Tp> + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : value(_VSTD::forward<_Tp>(__t)) @@ -261,17 +274,8 @@ public: >::value)), "Attempted to construct a reference element in a tuple with an rvalue");} - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR_AFTER_CXX11 - __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value) - : value(__t.get()) - {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");} - - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR_AFTER_CXX11 - __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value) - : value(_VSTD::forward<_Hp>(__t.get())) - {} + __tuple_leaf(const __tuple_leaf& __t) = default; + __tuple_leaf(__tuple_leaf&& __t) = default; template _LIBCPP_INLINE_VISIBILITY @@ -318,7 +322,13 @@ public: : _Hp(__a) {} template ::value>::type> + class = typename enable_if< + __lazy_and< + __lazy_not::type, __tuple_leaf>> + , is_constructible<_Hp, _Tp> + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : _Hp(_VSTD::forward<_Tp>(__t)) {} @@ -338,6 +348,9 @@ public: explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : _Hp(_VSTD::forward<_Tp>(__t), __a) {} + __tuple_leaf(__tuple_leaf const &) = default; + __tuple_leaf(__tuple_leaf &&) = default; + template _LIBCPP_INLINE_VISIBILITY __tuple_leaf& @@ -363,19 +376,18 @@ template _LIBCPP_INLINE_VISIBILITY void __swallow(_Tp&&...) _NOEXCEPT {} -template struct __all; +template +struct __all + : is_same<__all<_Pred...>, __all<(_Pred, true)...>> +{ }; -template <> -struct __all<> -{ - static const bool value = true; -}; +template +struct __all_default_constructible; -template -struct __all<_B0, _Bp...> -{ - static const bool value = _B0 && __all<_Bp...>::value; -}; +template +struct __all_default_constructible<__tuple_types<_Tp...>> + : __all::value...> +{ }; // __tuple_impl @@ -499,6 +511,9 @@ class _LIBCPP_TYPE_VIS_ONLY tuple typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; public: + template ::value)...>::value + >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() _NOEXCEPT_(__all::value...>::value) {} @@ -534,6 +549,12 @@ public: sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types::type >::value, bool >::type = false @@ -541,7 +562,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(_Up&&... __u) _NOEXCEPT_(( - is_nothrow_constructible< + is_nothrow_constructible::type, typename __make_tuple_types::type, typename __make_tuple_indices::type, @@ -574,6 +595,12 @@ public: sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types::type >::value, bool >::type =false @@ -582,7 +609,7 @@ public: explicit tuple(_Up&&... __u) _NOEXCEPT_(( - is_nothrow_constructible< + is_nothrow_constructible::type, typename __make_tuple_types::type, typename __make_tuple_indices::type, @@ -607,6 +634,12 @@ public: sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types::type >::value >::type > @@ -796,7 +829,7 @@ constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept // tie template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT { @@ -816,13 +849,13 @@ namespace { const __ignore_t ignore = __ignore_t() template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template -struct ___make_tuple_return +struct __make_tuple_return_impl { typedef _Tp type; }; template -struct ___make_tuple_return > +struct __make_tuple_return_impl > { typedef _Tp& type; }; @@ -830,7 +863,7 @@ struct ___make_tuple_return > template struct __make_tuple_return { - typedef typename ___make_tuple_return::type>::type type; + typedef typename __make_tuple_return_impl::type>::type type; }; template @@ -856,7 +889,7 @@ struct __tuple_equal _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { - return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y); + return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y); } }; @@ -895,7 +928,7 @@ struct __tuple_less bool operator()(const _Tp& __x, const _Up& __y) { return __tuple_less<_Ip-1>()(__x, __y) || - (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y)); + (!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y)); } }; @@ -1044,8 +1077,8 @@ struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J typename __tuple_cat_return_ref&&, _Tuple0&&>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0) { - return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., - get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); + return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., + _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); } template @@ -1060,8 +1093,8 @@ struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J typename __make_tuple_indices::value>::type, typename __make_tuple_indices::value>::type>() (forward_as_tuple( - _VSTD::forward<_Types>(get<_I0>(__t))..., - get<_J0>(_VSTD::forward<_Tuple0>(__t0))... + _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., + _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))... ), _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...); @@ -1090,8 +1123,8 @@ inline _LIBCPP_INLINE_VISIBILITY pair<_T1, _T2>::pair(piecewise_construct_t, tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) - : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...), - second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...), + second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) { } diff --git a/contrib/libc++/include/type_traits b/contrib/libc++/include/type_traits index fd6aa05e8..f4677358a 100644 --- a/contrib/libc++/include/type_traits +++ b/contrib/libc++/include/type_traits @@ -91,6 +91,7 @@ namespace std template struct is_empty; template struct is_polymorphic; template struct is_abstract; + template struct is_final; // C++14 template struct is_constructible; template struct is_default_constructible; @@ -196,7 +197,9 @@ namespace std template using result_of_t = typename result_of::type; // C++14 -} // std + template + using void_t = void; +} // C++17 */ #include <__config> @@ -208,6 +211,11 @@ namespace std _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_VARIADICS +template +struct __void_t { typedef void type; }; +#endif + template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template @@ -217,6 +225,9 @@ template template using conditional_t = typename conditional<_Bp, _If, _Then>::type; #endif +template struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {}; +template struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {typedef typename _Tp::type type;}; + template struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef _Tp type;}; @@ -236,10 +247,10 @@ struct _LIBCPP_TYPE_VIS_ONLY integral_constant typedef _Tp value_type; typedef integral_constant type; _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR operator value_type() const {return value;} + _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} #if _LIBCPP_STD_VER > 11 _LIBCPP_INLINE_VISIBILITY - constexpr value_type operator ()() const {return value;} + constexpr value_type operator ()() const _NOEXCEPT {return value;} #endif }; @@ -293,15 +304,15 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_void // __is_nullptr_t -template struct __libcpp___is_nullptr : public false_type {}; -template <> struct __libcpp___is_nullptr : public true_type {}; +template struct __is_nullptr_t_impl : public false_type {}; +template <> struct __is_nullptr_t_impl : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t - : public __libcpp___is_nullptr::type> {}; + : public __is_nullptr_t_impl::type> {}; #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer - : public __libcpp___is_nullptr::type> {}; + : public __is_nullptr_t_impl::type> {}; #endif // is_integral @@ -324,6 +335,10 @@ template <> struct __libcpp_is_integral : public tr template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __libcpp_is_integral<__int128_t> : public true_type {}; +template <> struct __libcpp_is_integral<__uint128_t> : public true_type {}; +#endif template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; @@ -371,13 +386,9 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public t template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif -#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -#define _LIBCPP_HAS_TYPE_TRAITS -#endif - // is_union -#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(is_union) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY is_union : public integral_constant {}; @@ -392,7 +403,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_union // is_class -#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(is_class) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant {}; @@ -417,7 +428,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : // is_function -namespace __is_function_imp +namespace __libcpp_is_function_imp { template char __test(_Tp*); template __two __test(...); @@ -430,7 +441,7 @@ template ::value || is_reference<_Tp>::value || __is_nullptr_t<_Tp>::value > struct __libcpp_is_function - : public integral_constant(__is_function_imp::__source<_Tp>())) == 1> + : public integral_constant(__libcpp_is_function_imp::__source<_Tp>())) == 1> {}; template struct __libcpp_is_function<_Tp, true> : public false_type {}; @@ -450,13 +461,13 @@ struct __member_pointer_traits_imp namespace __libcpp_is_member_function_pointer_imp { - template - char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); + template + char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); - template - std::__two __test(...); + template + std::__two __test(...); }; - + template struct __libcpp_is_member_function_pointer : public integral_constant(nullptr)) == 1> {}; @@ -479,7 +490,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer // is_enum -#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(is_enum) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant {}; @@ -662,13 +673,13 @@ template using add_pointer_t = typename add_pointer<_Tp>::type; // is_signed template ::value> -struct ___is_signed : public integral_constant {}; +struct __libcpp_is_signed_impl : public integral_constant {}; template -struct ___is_signed<_Tp, false> : public true_type {}; // floating point +struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point template ::value> -struct __libcpp_is_signed : public ___is_signed<_Tp> {}; +struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; template struct __libcpp_is_signed<_Tp, false> : public false_type {}; @@ -677,13 +688,13 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is // is_unsigned template ::value> -struct ___is_unsigned : public integral_constant {}; +struct __libcpp_is_unsigned_impl : public integral_constant {}; template -struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point +struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point template ::value> -struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; +struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; @@ -777,6 +788,13 @@ template struct __libcpp_abstract<_Tp, false> : public false_type {} template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; +// is_final + +#if _LIBCPP_STD_VER > 11 && __has_feature(is_final) +template struct _LIBCPP_TYPE_VIS_ONLY +is_final : public integral_constant {}; +#endif + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF @@ -785,7 +803,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant {}; -#else // __has_feature(is_base_of) +#else // _LIBCPP_HAS_IS_BASE_OF namespace __is_base_of_imp { @@ -810,7 +828,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant::value && sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; -#endif // __has_feature(is_base_of) +#endif // _LIBCPP_HAS_IS_BASE_OF // is_convertible @@ -933,7 +951,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_convertible // is_empty -#if __has_feature(is_empty) +#if __has_feature(is_empty) || (_GNUC_VER >= 407) template struct _LIBCPP_TYPE_VIS_ONLY is_empty @@ -964,7 +982,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_emp // is_polymorphic -#if __has_feature(is_polymorphic) +#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC) template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic @@ -984,17 +1002,17 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic // has_virtual_destructor -#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public integral_constant {}; -#else // _LIBCPP_HAS_TYPE_TRAITS +#else template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public false_type {}; -#endif // _LIBCPP_HAS_TYPE_TRAITS +#endif // alignment_of @@ -1169,45 +1187,77 @@ template using aligned_union_t = typename aligned #endif // _LIBCPP_HAS_NO_VARIADICS +template +struct __numeric_type +{ + static void __test(...); + static float __test(float); + static double __test(char); + static double __test(int); + static double __test(unsigned); + static double __test(long); + static double __test(unsigned long); + static double __test(long long); + static double __test(unsigned long long); + static double __test(double); + static long double __test(long double); + + typedef decltype(__test(declval<_Tp>())) type; + static const bool value = !is_same::value; +}; + +template <> +struct __numeric_type +{ + static const bool value = true; +}; + // __promote template ::value || is_void<_A1>::value) && - (is_arithmetic<_A2>::value || is_void<_A2>::value) && - (is_arithmetic<_A3>::value || is_void<_A3>::value)> -class __promote {}; + bool = __numeric_type<_A1>::value && + __numeric_type<_A2>::value && + __numeric_type<_A3>::value> +class __promote_imp +{ +public: + static const bool value = false; +}; template -class __promote<_A1, _A2, _A3, true> +class __promote_imp<_A1, _A2, _A3, true> { private: - typedef typename __promote<_A1>::type __type1; - typedef typename __promote<_A2>::type __type2; - typedef typename __promote<_A3>::type __type3; + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; + typedef typename __promote_imp<_A3>::type __type3; public: typedef decltype(__type1() + __type2() + __type3()) type; + static const bool value = true; }; template -class __promote<_A1, _A2, void, true> +class __promote_imp<_A1, _A2, void, true> { private: - typedef typename __promote<_A1>::type __type1; - typedef typename __promote<_A2>::type __type2; + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; public: typedef decltype(__type1() + __type2()) type; + static const bool value = true; }; template -class __promote<_A1, void, void, true> +class __promote_imp<_A1, void, void, true> { public: - typedef typename conditional::value, - typename conditional::value, double, _A1>::type, - void - >::type type; + typedef typename __numeric_type<_A1>::type type; + static const bool value = true; }; +template +class __promote : public __promote_imp<_A1, _A2, _A3> {}; + #ifdef _LIBCPP_STORE_AS_OPTIMIZATION // __transform @@ -1228,7 +1278,13 @@ typedef __type_list +#endif > > > > > __signed_types; typedef @@ -1237,7 +1293,13 @@ typedef __type_list +#endif > > > > > __unsigned_types; template struct __find_first; @@ -1321,6 +1383,10 @@ template <> struct __make_signed< signed long, true> {typedef long ty template <> struct __make_signed {typedef long type;}; template <> struct __make_signed< signed long long, true> {typedef long long type;}; template <> struct __make_signed {typedef long long type;}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; +template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; +#endif template struct _LIBCPP_TYPE_VIS_ONLY make_signed @@ -1350,6 +1416,10 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l template <> struct __make_unsigned {typedef unsigned long type;}; template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; template <> struct __make_unsigned {typedef unsigned long long type;}; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; +template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; +#endif template struct _LIBCPP_TYPE_VIS_ONLY make_unsigned @@ -1374,7 +1444,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> { public: - typedef _Tp type; + typedef typename decay<_Tp>::type type; }; template @@ -1466,7 +1536,7 @@ struct is_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, - const typename add_lvalue_reference<_Tp>::type> {}; + typename add_lvalue_reference::type>::type> {}; // is_move_assignable @@ -1480,42 +1550,61 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable // is_destructible -template -struct __destructible_test -{ - _Tp __t; +// if it's a reference, return true +// if it's a function, return false +// if it's void, return false +// if it's an array of unknown bound, return false +// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed +// where _Up is remove_all_extents<_Tp>::type + +template +struct __is_destructible_apply { typedef int type; }; + +template +struct __is_destructor_wellformed { + template + static char __test ( + typename __is_destructible_apply().~_Tp1())>::type + ); + + template + static __two __test (...); + + static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); }; +template +struct __destructible_imp; + template -decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -__is_destructible_test(_Tp&&); -#else -__is_destructible_test(_Tp&); -#endif +struct __destructible_imp<_Tp, false> + : public _VSTD::integral_constant::type>::value> {}; -false_type -__is_destructible_test(__any); +template +struct __destructible_imp<_Tp, true> + : public _VSTD::true_type {}; -template ::value || is_abstract<_Tp>::value - || is_function<_Tp>::value> -struct __destructible_imp - : public common_type - < - decltype(__is_destructible_test(declval<_Tp>())) - >::type {}; +template +struct __destructible_false; template -struct __destructible_imp<_Tp, true> - : public false_type {}; +struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {}; + +template +struct __destructible_false<_Tp, true> : public _VSTD::false_type {}; template struct is_destructible - : public __destructible_imp<_Tp> {}; + : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {}; template struct is_destructible<_Tp[]> - : public false_type {}; + : public _VSTD::false_type {}; + +template <> +struct is_destructible + : public _VSTD::false_type {}; // move @@ -1621,6 +1710,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> +{ + typedef _Class _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> { @@ -1629,6 +1726,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> +{ + typedef _Class const _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> { @@ -1637,6 +1742,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, fa typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> +{ + typedef _Class volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> { @@ -1645,6 +1758,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, tr typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> +{ + typedef _Class const volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + #if __has_feature(cxx_reference_qualified_functions) template @@ -1655,6 +1776,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> +{ + typedef _Class& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> { @@ -1663,6 +1792,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, fals typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> +{ + typedef _Class const& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> { @@ -1671,6 +1808,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, f typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> +{ + typedef _Class volatile& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> { @@ -1679,6 +1824,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, t typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> +{ + typedef _Class const volatile& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> { @@ -1687,6 +1840,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> +{ + typedef _Class&& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> { @@ -1695,6 +1856,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, fal typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> +{ + typedef _Class const&& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> { @@ -1703,6 +1872,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> +{ + typedef _Class volatile&& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> { @@ -1711,6 +1888,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, typedef _Rp (_FnType) (_Param...); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> +{ + typedef _Class const volatile&& _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param..., ...); +}; + #endif // __has_feature(cxx_reference_qualified_functions) #else // _LIBCPP_HAS_NO_VARIADICS @@ -1723,6 +1908,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> typedef _Rp (_FnType) (); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false> +{ + typedef _Class _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> { @@ -1731,6 +1924,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> typedef _Rp (_FnType) (_P0); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false> +{ + typedef _Class _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> { @@ -1739,6 +1940,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> typedef _Rp (_FnType) (_P0, _P1); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false> +{ + typedef _Class _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> { @@ -1747,6 +1956,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> typedef _Rp (_FnType) (_P0, _P1, _P2); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false> +{ + typedef _Class _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> { @@ -1755,6 +1972,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> typedef _Rp (_FnType) (); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false> +{ + typedef _Class const _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> { @@ -1763,6 +1988,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> typedef _Rp (_FnType) (_P0); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false> +{ + typedef _Class const _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> { @@ -1771,6 +2004,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> typedef _Rp (_FnType) (_P0, _P1); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false> +{ + typedef _Class const _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> { @@ -1779,6 +2020,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, f typedef _Rp (_FnType) (_P0, _P1, _P2); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false> +{ + typedef _Class const _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> { @@ -1787,6 +2036,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> typedef _Rp (_FnType) (); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false> +{ + typedef _Class volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> { @@ -1795,6 +2052,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> typedef _Rp (_FnType) (_P0); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false> +{ + typedef _Class volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> { @@ -1803,6 +2068,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, fal typedef _Rp (_FnType) (_P0, _P1); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false> +{ + typedef _Class volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> { @@ -1811,6 +2084,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true typedef _Rp (_FnType) (_P0, _P1, _P2); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false> +{ + typedef _Class volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> { @@ -1819,6 +2100,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false typedef _Rp (_FnType) (); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false> +{ + typedef _Class const volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> { @@ -1827,6 +2116,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, fa typedef _Rp (_FnType) (_P0); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false> +{ + typedef _Class const volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> { @@ -1835,6 +2132,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, tru typedef _Rp (_FnType) (_P0, _P1); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false> +{ + typedef _Class const volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, ...); +}; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> { @@ -1843,6 +2148,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile typedef _Rp (_FnType) (_P0, _P1, _P2); }; +template +struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false> +{ + typedef _Class const volatile _ClassType; + typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2, ...); +}; + #endif // _LIBCPP_HAS_NO_VARIADICS template @@ -2337,8 +2650,8 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible - : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> - {}; + : public is_constructible<_Tp, + typename add_lvalue_reference::type>::type> {}; // is_move_constructible @@ -2373,7 +2686,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> -#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2502,7 +2815,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl // is_trivially_assignable -#if __has_feature(is_trivially_constructible) +#if __has_feature(is_trivially_assignable) template struct is_trivially_assignable @@ -2510,7 +2823,7 @@ struct is_trivially_assignable { }; -#else // !__has_feature(is_trivially_constructible) +#else // !__has_feature(is_trivially_assignable) template struct is_trivially_assignable @@ -2536,14 +2849,13 @@ struct is_trivially_assignable<_Tp&, _Tp&&> #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif // !__has_feature(is_trivially_constructible) +#endif // !__has_feature(is_trivially_assignable) // is_trivially_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable::type, - const typename add_lvalue_reference<_Tp>::type> - {}; + typename add_lvalue_reference::type>::type> {}; // is_trivially_move_assignable @@ -2558,12 +2870,12 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable // is_trivially_destructible -#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible - : public integral_constant {}; + : public integral_constant::value && __has_trivial_destructor(_Tp)> {}; -#else // _LIBCPP_HAS_TYPE_TRAITS +#else template struct __libcpp_trivial_destructor : public integral_constant::value || @@ -2572,7 +2884,7 @@ template struct __libcpp_trivial_destructor template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; -#endif // _LIBCPP_HAS_TYPE_TRAITS +#endif // is_nothrow_constructible @@ -2587,31 +2899,40 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS -#if __has_feature(cxx_noexcept) +#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) -template struct __libcpp_is_nothrow_constructible; +template struct __libcpp_is_nothrow_constructible; template -struct __libcpp_is_nothrow_constructible +struct __libcpp_is_nothrow_constructible : public integral_constant()...))> { }; -template -struct __libcpp_is_nothrow_constructible +template +void __implicit_conversion_to(_Tp) noexcept { } + +template +struct __libcpp_is_nothrow_constructible + : public integral_constant(declval<_Arg>()))> +{ +}; + +template +struct __libcpp_is_nothrow_constructible : public false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible - : __libcpp_is_nothrow_constructible::value, _Tp, _Args...> + : __libcpp_is_nothrow_constructible::value, is_reference<_Tp>::value, _Tp, _Args...> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> - : __libcpp_is_nothrow_constructible::value, _Tp> + : __libcpp_is_nothrow_constructible::value, is_reference<_Tp>::value, _Tp> { }; @@ -2625,7 +2946,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> -#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2639,7 +2960,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> #else struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> #endif -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2649,7 +2970,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2659,7 +2980,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2681,7 +3002,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> -#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2692,7 +3013,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, __is_construct::__nat> -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2703,7 +3024,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, __is_construct::__nat> -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2714,7 +3035,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, __is_construct::__nat> -#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403) : integral_constant #else : integral_constant::value> @@ -2734,8 +3055,8 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructib // is_nothrow_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible - : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> - {}; + : public is_nothrow_constructible<_Tp, + typename add_lvalue_reference::type>::type> {}; // is_nothrow_move_constructible @@ -2749,7 +3070,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible // is_nothrow_assignable -#if __has_feature(cxx_noexcept) +#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) template struct __libcpp_is_nothrow_assignable; @@ -2779,7 +3100,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> -#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) : integral_constant {}; #else : integral_constant::value> {}; @@ -2787,7 +3108,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> -#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) : integral_constant {}; #else : integral_constant::value> {}; @@ -2795,7 +3116,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> -#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) : integral_constant {}; #else : integral_constant::value> {}; @@ -2805,7 +3126,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> template struct is_nothrow_assignable<_Tp&, _Tp&&> -#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403) : integral_constant {}; #else : integral_constant::value> {}; @@ -2819,8 +3140,7 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, - const typename add_lvalue_reference<_Tp>::type> - {}; + typename add_lvalue_reference::type>::type> {}; // is_nothrow_move_assignable @@ -2835,7 +3155,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable // is_nothrow_destructible -#if __has_feature(cxx_noexcept) +#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) template struct __libcpp_is_nothrow_destructible; @@ -2892,12 +3212,12 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible // is_pod -#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if __has_feature(is_pod) || (_GNUC_VER >= 403) template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant {}; -#else // _LIBCPP_HAS_TYPE_TRAITS +#else template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant::value && @@ -2905,13 +3225,13 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_pod is_trivially_copy_assignable<_Tp>::value && is_trivially_destructible<_Tp>::value> {}; -#endif // _LIBCPP_HAS_TYPE_TRAITS +#endif // is_literal_type; template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type -#if __has_feature(is_literal) - : public integral_constant +#ifdef _LIBCPP_IS_LITERAL + : public integral_constant #else : integral_constant::type>::value || is_reference::type>::value> @@ -2921,7 +3241,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type // is_standard_layout; template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout -#if __has_feature(is_standard_layout) +#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407) : public integral_constant #else : integral_constant::type>::value> @@ -2941,7 +3261,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial -#if __has_feature(is_trivial) +#if __has_feature(is_trivial) || (_GNUC_VER >= 407) : public integral_constant #else : integral_constant::value && @@ -3110,7 +3430,7 @@ template ::type>::value && - is_base_of::type>::_ClassType, + is_base_of::type>::_ClassType>::type, typename remove_reference<_A0>::type>::value >::type > @@ -3123,7 +3443,7 @@ template ::type>::value && - !is_base_of::type>::_ClassType, + !is_base_of::type>::_ClassType>::type, typename remove_reference<_A0>::type>::value >::type > @@ -3271,7 +3591,7 @@ struct __is_swappable { }; -#if __has_feature(cxx_noexcept) +#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) template struct __is_nothrow_swappable_imp @@ -3302,19 +3622,19 @@ struct __is_nothrow_swappable #endif // __has_feature(cxx_noexcept) -#ifdef _LIBCXX_UNDERLYING_TYPE +#ifdef _LIBCPP_UNDERLYING_TYPE template struct underlying_type { - typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; + typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type; }; #if _LIBCPP_STD_VER > 11 template using underlying_type_t = typename underlying_type<_Tp>::type; #endif -#else // _LIBCXX_UNDERLYING_TYPE +#else // _LIBCPP_UNDERLYING_TYPE template struct underlying_type @@ -3324,29 +3644,46 @@ struct underlying_type "libc++ does not know how to use it."); }; -#endif // _LIBCXX_UNDERLYING_TYPE +#endif // _LIBCPP_UNDERLYING_TYPE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE template -struct __has_operator_addressof_imp +struct __has_operator_addressof_member_imp { + template + static auto __test(int) + -> typename __select_2nd().operator&()), true_type>::type; template - static auto __test(__any) -> false_type; + static auto __test(long) -> false_type; + + static const bool value = decltype(__test<_Tp>(0))::value; +}; + +template +struct __has_operator_addressof_free_imp +{ template - static auto __test(_Up* __u) - -> typename __select_2ndoperator&()), true_type>::type; + static auto __test(int) + -> typename __select_2nd())), true_type>::type; + template + static auto __test(long) -> false_type; - static const bool value = decltype(__test<_Tp>(nullptr))::value; + static const bool value = decltype(__test<_Tp>(0))::value; }; template struct __has_operator_addressof - : public integral_constant::value> + : public integral_constant::value + || __has_operator_addressof_free_imp<_Tp>::value> {}; #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if _LIBCPP_STD_VER > 14 +template using void_t = void; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS diff --git a/contrib/libc++/include/typeinfo b/contrib/libc++/include/typeinfo index 6ffee0f8a..14ef77b31 100644 --- a/contrib/libc++/include/typeinfo +++ b/contrib/libc++/include/typeinfo @@ -60,6 +60,7 @@ public: #include <__config> #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -73,32 +74,75 @@ class _LIBCPP_EXCEPTION_ABI type_info type_info& operator=(const type_info&); type_info(const type_info&); protected: +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT const char* __type_name; +#else + // A const char* with the non-unique RTTI bit possibly set. + uintptr_t __type_name; +#endif _LIBCPP_INLINE_VISIBILITY explicit type_info(const char* __n) +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT : __type_name(__n) {} +#else + : __type_name(reinterpret_cast(__n)) {} +#endif public: virtual ~type_info(); _LIBCPP_INLINE_VISIBILITY - const char* name() const _NOEXCEPT {return __type_name;} + const char* name() const _NOEXCEPT +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT + {return __type_name;} +#else + {return reinterpret_cast(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);} +#endif _LIBCPP_INLINE_VISIBILITY bool before(const type_info& __arg) const _NOEXCEPT +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT {return __type_name < __arg.__type_name;} +#else + {if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT)) + return __type_name < __arg.__type_name; + return __compare_nonunique_names(__arg) < 0;} +#endif + _LIBCPP_INLINE_VISIBILITY size_t hash_code() const _NOEXCEPT +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT {return *reinterpret_cast(&__type_name);} +#else + {if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name; + const char *__ptr = name(); + size_t __hash = 5381; + while (unsigned char __c = static_cast(*__ptr++)) + __hash = (__hash * 33) ^ __c; + return __hash;} +#endif _LIBCPP_INLINE_VISIBILITY bool operator==(const type_info& __arg) const _NOEXCEPT +#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT {return __type_name == __arg.__type_name;} +#else + {if (__type_name == __arg.__type_name) return true; + if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT)) + return false; + return __compare_nonunique_names(__arg) == 0;} +#endif _LIBCPP_INLINE_VISIBILITY bool operator!=(const type_info& __arg) const _NOEXCEPT {return !operator==(__arg);} +#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT + private: + _LIBCPP_INLINE_VISIBILITY + int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT + {return __builtin_strcmp(name(), __arg.name());} +#endif }; class _LIBCPP_EXCEPTION_ABI bad_cast diff --git a/contrib/libc++/include/unordered_map b/contrib/libc++/include/unordered_map index 4e2298bf9..0fa87d19a 100644 --- a/contrib/libc++/include/unordered_map +++ b/contrib/libc++/include/unordered_map @@ -351,6 +351,8 @@ template #include #include +#include <__debug> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/contrib/libc++/include/unordered_set b/contrib/libc++/include/unordered_set index fd378fa07..d06629fdc 100644 --- a/contrib/libc++/include/unordered_set +++ b/contrib/libc++/include/unordered_set @@ -325,6 +325,8 @@ template #include <__hash_table> #include +#include <__debug> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/contrib/libc++/include/utility b/contrib/libc++/include/utility index 2c1f62ccb..6f324dbd6 100644 --- a/contrib/libc++/include/utility +++ b/contrib/libc++/include/utility @@ -101,30 +101,30 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); template class tuple_size; template class tuple_element; -template struct tuple_size >; -template struct tuple_element<0, std::pair >; -template struct tuple_element<1, std::pair >; +template struct tuple_size >; +template struct tuple_element<0, pair >; +template struct tuple_element<1, pair >; template - typename tuple_element >::type& - get(std::pair&) noexcept; // constexpr in C++14 + typename tuple_element >::type& + get(pair&) noexcept; // constexpr in C++14 template - const typename const tuple_element >::type& - get(const std::pair&) noexcept; // constexpr in C++14 + const typename const tuple_element >::type& + get(const pair&) noexcept; // constexpr in C++14 template - typename tuple_element >::type&& - get(std::pair&&) noexcept; // constexpr in C++14 + typename tuple_element >::type&& + get(pair&&) noexcept; // constexpr in C++14 template - constexpr T1& get(std::pair&) noexcept; // C++14 + constexpr T1& get(pair&) noexcept; // C++14 template - constexpr T1 const& get(std::pair const &) noexcept; // C++14 + constexpr T1 const& get(pair const &) noexcept; // C++14 template - constexpr T1&& get(std::pair&&) noexcept; // C++14 + constexpr T1&& get(pair&&) noexcept; // C++14 // C++14 @@ -207,7 +207,7 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator2 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { - for(; __first1 != __last1; ++__first1, ++__first2) + for(; __first1 != __last1; ++__first1, (void) ++__first2) swap(*__first1, *__first2); return __first2; } @@ -345,9 +345,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_Tuple&& __p) : first(_VSTD::forward::type>::type>(get<0>(__p))), + typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))), second(_VSTD::forward::type>::type>(get<1>(__p))) + typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p))) {} @@ -465,13 +465,13 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template -struct ___make_pair_return +struct __make_pair_return_impl { typedef _Tp type; }; template -struct ___make_pair_return> +struct __make_pair_return_impl> { typedef _Tp& type; }; @@ -479,7 +479,7 @@ struct ___make_pair_return> template struct __make_pair_return { - typedef typename ___make_pair_return::type>::type type; + typedef typename __make_pair_return_impl::type>::type type; }; template diff --git a/contrib/libc++/include/valarray b/contrib/libc++/include/valarray index 5113516e9..2b942046d 100644 --- a/contrib/libc++/include/valarray +++ b/contrib/libc++/include/valarray @@ -345,6 +345,7 @@ template unspecified2 end(const valarray& v); #include #include #include +#include #include <__undef_min_max> @@ -1219,6 +1220,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const const value_type* __s = __sa.__vp_; for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) *__t = *__s; + return *this; } template @@ -2089,6 +2091,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; + return *this; } template @@ -2636,7 +2639,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(result_type))); + static_cast(_VSTD::__allocate(__n * sizeof(result_type))); for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) ::new (__r.__end_) result_type(__expr_[__i]); } @@ -2670,7 +2673,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n) { if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2695,7 +2698,7 @@ valarray<_Tp>::valarray(const valarray& __v) { if (__v.size()) { - __begin_ = __end_ = static_cast(::operator new(__v.size() * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__v.size() * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2736,7 +2739,7 @@ valarray<_Tp>::valarray(initializer_list __il) size_t __n = __il.size(); if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2764,7 +2767,7 @@ valarray<_Tp>::valarray(const slice_array& __sa) size_t __n = __sa.__size_; if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2790,7 +2793,7 @@ valarray<_Tp>::valarray(const gslice_array& __ga) size_t __n = __ga.__1d_.size(); if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2819,7 +2822,7 @@ valarray<_Tp>::valarray(const mask_array& __ma) size_t __n = __ma.__1d_.size(); if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -2848,7 +2851,7 @@ valarray<_Tp>::valarray(const indirect_array& __ia) size_t __n = __ia.__1d_.size(); if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { @@ -3133,7 +3136,7 @@ valarray<_Tp>::operator+() const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(+*__p); } @@ -3150,7 +3153,7 @@ valarray<_Tp>::operator-() const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(-*__p); } @@ -3167,7 +3170,7 @@ valarray<_Tp>::operator~() const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(~*__p); } @@ -3184,7 +3187,7 @@ valarray<_Tp>::operator!() const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(bool))); + static_cast(_VSTD::__allocate(__n * sizeof(bool))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) bool(!*__p); } @@ -3504,7 +3507,7 @@ valarray<_Tp>::shift(int __i) const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); const value_type* __sb; value_type* __tb; value_type* __te; @@ -3542,7 +3545,7 @@ valarray<_Tp>::cshift(int __i) const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); __i %= static_cast(__n); const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) @@ -3563,7 +3566,7 @@ valarray<_Tp>::apply(value_type __f(value_type)) const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(__f(*__p)); } @@ -3580,7 +3583,7 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const { __r.__begin_ = __r.__end_ = - static_cast(::operator new(__n * sizeof(value_type))); + static_cast(_VSTD::__allocate(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(__f(*__p)); } @@ -3595,12 +3598,12 @@ valarray<_Tp>::resize(size_t __n, value_type __x) { while (__end_ != __begin_) (--__end_)->~value_type(); - ::operator delete(__begin_); + _VSTD::__deallocate(__begin_); __begin_ = __end_ = nullptr; } if (__n) { - __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); + __begin_ = __end_ = static_cast(_VSTD::__allocate(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { diff --git a/contrib/libc++/include/vector b/contrib/libc++/include/vector index 6ac78d5d5..22a63439a 100644 --- a/contrib/libc++/include/vector +++ b/contrib/libc++/include/vector @@ -276,11 +276,7 @@ void swap(vector& x, vector& y) #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG -# include <__debug> -#else -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif +#include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -483,6 +479,7 @@ class _LIBCPP_TYPE_VIS_ONLY vector { private: typedef __vector_base<_Tp, _Allocator> __base; + typedef allocator<_Tp> __default_allocator_type; public: typedef vector __self; typedef _Tp value_type; @@ -749,7 +746,9 @@ public: _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT { + size_type __old_size = size(); __base::clear(); + __annotate_shrink(__old_size); __invalidate_all_iterators(); } @@ -785,7 +784,6 @@ private: void >::type __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); - void __move_construct_at_end(pointer __first, pointer __last); void __append(size_type __n); void __append(size_type __n, const_reference __x); _LIBCPP_INLINE_VISIBILITY @@ -816,7 +814,9 @@ private: } __get_db()->unlock(); #endif + size_type __old_size = size(); __base::__destruct_at_end(__new_last); + __annotate_shrink(__old_size); } template void @@ -830,17 +830,76 @@ private: void __emplace_back_slow_path(_Args&&... __args); #endif + // The following functions are no-ops outside of AddressSanitizer mode. + // We call annotatations only for the default Allocator because other allocators + // may not meet the AddressSanitizer alignment constraints. + // See the documentation for __sanitizer_annotate_contiguous_container for more details. + void __annotate_contiguous_container + (const void *__beg, const void *__end, const void *__old_mid, const void *__new_mid) const + { +#ifndef _LIBCPP_HAS_NO_ASAN + if (__beg && is_same::value) + __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); +#endif + } + + void __annotate_new(size_type __current_size) const + { + __annotate_contiguous_container(data(), data() + capacity(), + data() + capacity(), data() + __current_size); + } + void __annotate_delete() const + { + __annotate_contiguous_container(data(), data() + capacity(), + data() + size(), data() + capacity()); + } + void __annotate_increase(size_type __n) const + { + __annotate_contiguous_container(data(), data() + capacity(), + data() + size(), data() + size() + __n); + } + void __annotate_shrink(size_type __old_size) const + { + __annotate_contiguous_container(data(), data() + capacity(), + data() + __old_size, data() + size()); + } +#ifndef _LIBCPP_HAS_NO_ASAN + // The annotation for size increase should happen before the actual increase, + // but if an exception is thrown after that the annotation has to be undone. + struct __RAII_IncreaseAnnotator { + __RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1) + : __commit(false), __v(__v), __n(__n) { + __v.__annotate_increase(__n); + } + void __done() { __commit = true; } + ~__RAII_IncreaseAnnotator() { + if (__commit) return; + __v.__annotate_shrink(__v.size() + __n); + } + bool __commit; + size_type __n; + const vector &__v; + }; +#else + struct __RAII_IncreaseAnnotator { + inline __RAII_IncreaseAnnotator(const vector &, size_type __n = 1) {} + inline void __done() {} + }; +#endif + }; template void vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v) { + __annotate_delete(); __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); _VSTD::swap(this->__begin_, __v.__begin_); _VSTD::swap(this->__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; + __annotate_new(size()); __invalidate_all_iterators(); } @@ -848,6 +907,7 @@ template typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v, pointer __p) { + __annotate_delete(); pointer __r = __v.__begin_; __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_); __alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_); @@ -855,6 +915,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; + __annotate_new(size()); __invalidate_all_iterators(); return __r; } @@ -874,6 +935,7 @@ vector<_Tp, _Allocator>::allocate(size_type __n) this->__throw_length_error(); this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); this->__end_cap() = this->__begin_ + __n; + __annotate_new(0); } template @@ -922,9 +984,11 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) allocator_type& __a = this->__alloc(); do { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); ++this->__end_; --__n; + __annotator.__done(); } while (__n > 0); } @@ -942,9 +1006,11 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) allocator_type& __a = this->__alloc(); do { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); ++this->__end_; --__n; + __annotator.__done(); } while (__n > 0); } @@ -960,20 +1026,9 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt allocator_type& __a = this->__alloc(); for (; __first != __last; ++__first) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - ++this->__end_; - } -} - -template -void -vector<_Tp, _Allocator>::__move_construct_at_end(pointer __first, pointer __last) -{ - allocator_type& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), - _VSTD::move(*__first)); + __annotator.__done(); ++this->__end_; } } @@ -1284,10 +1339,10 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { deallocate(); + __base::__move_assign_alloc(__c); // this can throw this->__begin_ = __c.__begin_; this->__end_ = __c.__end_; this->__end_cap() = __c.__end_cap(); - __base::__move_assign_alloc(__c); __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__c); @@ -1535,8 +1590,10 @@ vector<_Tp, _Allocator>::push_back(const_reference __x) { if (this->__end_ != this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), __x); + __annotator.__done(); ++this->__end_; } else @@ -1552,9 +1609,11 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x) { if (this->__end_ < this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::move(__x)); + __annotator.__done(); ++this->__end_; } else @@ -1584,9 +1643,11 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { if (this->__end_ < this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::forward<_Args>(__args)...); + __annotator.__done(); ++this->__end_; } else @@ -1666,6 +1727,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), @@ -1680,6 +1742,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) ++__xr; *__p = *__xr; } + __annotator.__done(); } else { @@ -1705,6 +1768,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), @@ -1717,6 +1781,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) __move_range(__p, this->__end_, __p + 1); *__p = _VSTD::move(__x); } + __annotator.__done(); } else { @@ -1743,6 +1808,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { + __RAII_IncreaseAnnotator __annotator(*this); if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), @@ -1756,6 +1822,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) __move_range(__p, this->__end_, __p + 1); *__p = _VSTD::move(__tmp); } + __annotator.__done(); } else { @@ -1794,7 +1861,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ } if (__n > 0) { + __RAII_IncreaseAnnotator __annotator(*this, __n); __move_range(__p, __old_last, __p + __old_n); + __annotator.__done(); const_pointer __xr = pointer_traits::pointer_to(__x); if (__p <= __xr && __xr < this->__end_) __xr += __old_n; @@ -1904,7 +1973,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi } if (__n > 0) { + __RAII_IncreaseAnnotator __annotator(*this, __n); __move_range(__p, __old_last, __p + __old_n); + __annotator.__done(); _VSTD::copy(__first, __m, __p); } } @@ -2297,7 +2368,7 @@ private: void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static size_type __align_it(size_type __new_size) _NOEXCEPT - {return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);}; + {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); template @@ -2796,10 +2867,10 @@ vector::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { deallocate(); + __move_assign_alloc(__c); this->__begin_ = __c.__begin_; this->__size_ = __c.__size_; this->__cap() = __c.__cap(); - __move_assign_alloc(__c); __c.__begin_ = nullptr; __c.__cap() = __c.__size_ = 0; } diff --git a/contrib/libc++/src/algorithm.cpp b/contrib/libc++/src/algorithm.cpp index 10c4c3312..e548856ff 100644 --- a/contrib/libc++/src/algorithm.cpp +++ b/contrib/libc++/src/algorithm.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #include "algorithm" #include "random" #include "mutex" @@ -48,12 +47,16 @@ template bool __insertion_sort_incomplete<__less&, long double*>(lo template unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&); +#ifndef _LIBCPP_HAS_NO_THREADS static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER; +#endif unsigned __rs_default::__c_ = 0; __rs_default::__rs_default() { +#ifndef _LIBCPP_HAS_NO_THREADS pthread_mutex_lock(&__rs_mut); +#endif __c_ = 1; } @@ -64,8 +67,12 @@ __rs_default::__rs_default(const __rs_default&) __rs_default::~__rs_default() { +#ifndef _LIBCPP_HAS_NO_THREADS if (--__c_ == 0) pthread_mutex_unlock(&__rs_mut); +#else + --__c_; +#endif } __rs_default::result_type diff --git a/contrib/libc++/src/chrono.cpp b/contrib/libc++/src/chrono.cpp index 15a6f466a..456941144 100644 --- a/contrib/libc++/src/chrono.cpp +++ b/contrib/libc++/src/chrono.cpp @@ -46,6 +46,7 @@ system_clock::from_time_t(time_t t) _NOEXCEPT return system_clock::time_point(seconds(t)); } +#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK // steady_clock const bool steady_clock::is_steady; @@ -108,10 +109,8 @@ steady_clock::now() _NOEXCEPT } #else // __APPLE__ -// FIXME: We assume that clock_gettime(CLOCK_MONOTONIC) works on -// non-apple systems. Instead, we should check _POSIX_TIMERS and -// _POSIX_MONOTONIC_CLOCK and fall back to something else if those -// don't exist. +// FIXME: if _LIBCPP_HAS_NO_MONOTONIC_CLOCK, then clock_gettime isn't going to +// work. It may be possible to fall back on something else, depending on the system. // Warning: If this is not truly steady, then it is non-conforming. It is // better for it to not exist and have the rest of libc++ use system_clock @@ -127,6 +126,8 @@ steady_clock::now() _NOEXCEPT } #endif // __APPLE__ +#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK + } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/src/condition_variable.cpp b/contrib/libc++/src/condition_variable.cpp index de0f6f47d..5fd5fc891 100644 --- a/contrib/libc++/src/condition_variable.cpp +++ b/contrib/libc++/src/condition_variable.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "__config" + +#ifndef _LIBCPP_HAS_NO_THREADS + #include "condition_variable" #include "thread" #include "system_error" @@ -32,7 +36,7 @@ condition_variable::notify_all() _NOEXCEPT } void -condition_variable::wait(unique_lock& lk) +condition_variable::wait(unique_lock& lk) _NOEXCEPT { if (!lk.owns_lock()) __throw_system_error(EPERM, @@ -44,7 +48,7 @@ condition_variable::wait(unique_lock& lk) void condition_variable::__do_timed_wait(unique_lock& lk, - chrono::time_point tp) + chrono::time_point tp) _NOEXCEPT { using namespace chrono; if (!lk.owns_lock()) @@ -79,3 +83,5 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock lk) } _LIBCPP_END_NAMESPACE_STD + +#endif // !_LIBCPP_HAS_NO_THREADS diff --git a/contrib/libc++/src/debug.cpp b/contrib/libc++/src/debug.cpp index d0e867957..60694a3bd 100644 --- a/contrib/libc++/src/debug.cpp +++ b/contrib/libc++/src/debug.cpp @@ -35,6 +35,7 @@ __get_const_db() namespace { +#ifndef _LIBCPP_HAS_NO_THREADS typedef mutex mutex_type; typedef lock_guard WLock; typedef lock_guard RLock; @@ -45,6 +46,7 @@ mut() static mutex_type m; return m; } +#endif // !_LIBCPP_HAS_NO_THREADS } // unnamed namespace @@ -108,7 +110,9 @@ __libcpp_db::~__libcpp_db() void* __libcpp_db::__find_c_from_i(void* __i) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database."); return i->__c_ != nullptr ? i->__c_->__c_ : nullptr; @@ -117,7 +121,9 @@ __libcpp_db::__find_c_from_i(void* __i) const void __libcpp_db::__insert_ic(void* __i, const void* __c) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif if (__cbeg_ == __cend_) return; size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); @@ -138,7 +144,9 @@ __libcpp_db::__insert_ic(void* __i, const void* __c) __c_node* __libcpp_db::__insert_c(void* __c) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif if (__csz_ + 1 > static_cast(__cend_ - __cbeg_)) { size_t nc = __next_prime(2*static_cast(__cend_ - __cbeg_) + 1); @@ -184,7 +192,9 @@ __libcpp_db::__insert_c(void* __c) void __libcpp_db::__erase_i(void* __i) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif if (__ibeg_ != __iend_) { size_t hi = hash()(__i) % static_cast(__iend_ - __ibeg_); @@ -215,7 +225,9 @@ __libcpp_db::__erase_i(void* __i) void __libcpp_db::__invalidate_all(void* __c) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif if (__cend_ != __cbeg_) { size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); @@ -239,17 +251,23 @@ __libcpp_db::__invalidate_all(void* __c) __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { +#ifndef _LIBCPP_HAS_NO_THREADS mut().lock(); +#endif if (__cend_ == __cbeg_) { +#ifndef _LIBCPP_HAS_NO_THREADS mut().unlock(); +#endif return nullptr; } size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; if (p == nullptr) { +#ifndef _LIBCPP_HAS_NO_THREADS mut().unlock(); +#endif return nullptr; } while (p->__c_ != __c) @@ -257,7 +275,9 @@ __libcpp_db::__find_c_and_lock(void* __c) const p = p->__next_; if (p == nullptr) { +#ifndef _LIBCPP_HAS_NO_THREADS mut().unlock(); +#endif return nullptr; } } @@ -281,13 +301,17 @@ __libcpp_db::__find_c(void* __c) const void __libcpp_db::unlock() const { +#ifndef _LIBCPP_HAS_NO_THREADS mut().unlock(); +#endif } void __libcpp_db::__erase_c(void* __c) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif if (__cend_ != __cbeg_) { size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); @@ -322,7 +346,9 @@ __libcpp_db::__erase_c(void* __c) void __libcpp_db::__iterator_copy(void* __i, const void* __i0) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif __i_node* i = __find_iterator(__i); __i_node* i0 = __find_iterator(__i0); __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr; @@ -348,7 +374,9 @@ __libcpp_db::__iterator_copy(void* __i, const void* __i0) bool __libcpp_db::__dereferenceable(const void* __i) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); return i != nullptr && i->__c_ != nullptr && i->__c_->__dereferenceable(__i); } @@ -356,7 +384,9 @@ __libcpp_db::__dereferenceable(const void* __i) const bool __libcpp_db::__decrementable(const void* __i) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i); } @@ -364,7 +394,9 @@ __libcpp_db::__decrementable(const void* __i) const bool __libcpp_db::__addable(const void* __i, ptrdiff_t __n) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); return i != nullptr && i->__c_ != nullptr && i->__c_->__addable(__i, __n); } @@ -372,7 +404,9 @@ __libcpp_db::__addable(const void* __i, ptrdiff_t __n) const bool __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n); } @@ -380,7 +414,9 @@ __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const bool __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const { +#ifndef _LIBCPP_HAS_NO_THREADS RLock _(mut()); +#endif __i_node* i = __find_iterator(__i); __i_node* j = __find_iterator(__j); __c_node* ci = i != nullptr ? i->__c_ : nullptr; @@ -391,7 +427,9 @@ __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const void __libcpp_db::swap(void* c1, void* c2) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif size_t hc = hash()(c1) % static_cast(__cend_ - __cbeg_); __c_node* p1 = __cbeg_[hc]; _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A"); @@ -420,7 +458,9 @@ __libcpp_db::swap(void* c1, void* c2) void __libcpp_db::__insert_i(void* __i) { +#ifndef _LIBCPP_HAS_NO_THREADS WLock _(mut()); +#endif __insert_iterator(__i); } diff --git a/contrib/libc++/src/exception.cpp b/contrib/libc++/src/exception.cpp index 3ce6f2e11..b5c46c080 100644 --- a/contrib/libc++/src/exception.cpp +++ b/contrib/libc++/src/exception.cpp @@ -16,7 +16,7 @@ #define __has_include(inc) 0 #endif -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(LIBCXXRT) #include using namespace __cxxabiv1; diff --git a/contrib/libc++/src/future.cpp b/contrib/libc++/src/future.cpp index 70919ab7d..0c5c2c448 100644 --- a/contrib/libc++/src/future.cpp +++ b/contrib/libc++/src/future.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "__config" + +#ifndef _LIBCPP_HAS_NO_THREADS + #include "future" #include "string" @@ -26,8 +30,13 @@ __future_error_category::name() const _NOEXCEPT return "future"; } +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wswitch" +#elif defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" +#endif string __future_error_category::message(int ev) const @@ -50,7 +59,11 @@ __future_error_category::message(int ev) const return string("unspecified future_errc value\n"); } +#if defined(__clang__) #pragma clang diagnostic pop +#elif defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif const error_category& future_category() _NOEXCEPT @@ -289,3 +302,5 @@ shared_future::operator=(const shared_future& __rhs) } _LIBCPP_END_NAMESPACE_STD + +#endif // !_LIBCPP_HAS_NO_THREADS diff --git a/contrib/libc++/src/hash.cpp b/contrib/libc++/src/hash.cpp index 388ab2ebe..dc90f789c 100644 --- a/contrib/libc++/src/hash.cpp +++ b/contrib/libc++/src/hash.cpp @@ -136,7 +136,7 @@ const unsigned indices[] = // The algorithm creates a list of small primes, plus an open-ended list of // potential primes. All prime numbers are potential prime numbers. However // some potential prime numbers are not prime. In an ideal world, all potential -// prime numbers would be prime. Candiate prime numbers are chosen as the next +// prime numbers would be prime. Candidate prime numbers are chosen as the next // highest potential prime. Then this number is tested for prime by dividing it // by all potential prime numbers less than the sqrt of the candidate. // diff --git a/contrib/libc++/src/ios.cpp b/contrib/libc++/src/ios.cpp index bbe3c072e..d879beb38 100644 --- a/contrib/libc++/src/ios.cpp +++ b/contrib/libc++/src/ios.cpp @@ -7,8 +7,7 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; - +#include "__config" #include "ios" #include "streambuf" #include "istream" @@ -54,9 +53,9 @@ string __iostream_category::message(int ev) const { if (ev != static_cast(io_errc::stream) -#ifdef ELAST - && ev <= ELAST -#endif +#ifdef _LIBCPP_ELAST + && ev <= _LIBCPP_ELAST +#endif // _LIBCPP_ELAST ) return __do_message::message(ev); return string("unspecified iostream_category error"); @@ -134,7 +133,7 @@ locale ios_base::imbue(const locale& newloc) { static_assert(sizeof(locale) == sizeof(__loc_), ""); - locale& loc_storage = *(locale*)&__loc_; + locale& loc_storage = *reinterpret_cast(&__loc_); locale oldloc = loc_storage; loc_storage = newloc; __call_callbacks(imbue_event); @@ -144,17 +143,27 @@ ios_base::imbue(const locale& newloc) locale ios_base::getloc() const { - const locale& loc_storage = *(locale*)&__loc_; + const locale& loc_storage = *reinterpret_cast(&__loc_); return loc_storage; } // xalloc -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0); #else int ios_base::__xindex_ = 0; #endif +template +static size_t __ios_new_cap(size_t __req_size, size_t __current_cap) +{ // Precondition: __req_size > __current_cap + const size_t mx = std::numeric_limits::max() / sizeof(_Tp); + if (__req_size < mx/2) + return _VSTD::max(2 * __current_cap, __req_size); + else + return mx; +} + int ios_base::xalloc() { @@ -167,13 +176,8 @@ ios_base::iword(int index) size_t req_size = static_cast(index)+1; if (req_size > __iarray_cap_) { - size_t newcap; - const size_t mx = std::numeric_limits::max(); - if (req_size < mx/2) - newcap = _VSTD::max(2 * __iarray_cap_, req_size); - else - newcap = mx; - long* iarray = (long*)realloc(__iarray_, newcap * sizeof(long)); + size_t newcap = __ios_new_cap(req_size, __iarray_cap_); + long* iarray = static_cast(realloc(__iarray_, newcap * sizeof(long))); if (iarray == 0) { setstate(badbit); @@ -182,8 +186,9 @@ ios_base::iword(int index) return error; } __iarray_ = iarray; - for (long* p = __iarray_ + __iarray_size_; __iarray_cap_ < newcap; ++__iarray_cap_, ++p) + for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p) *p = 0; + __iarray_cap_ = newcap; } __iarray_size_ = max(__iarray_size_, req_size); return __iarray_[index]; @@ -195,13 +200,8 @@ ios_base::pword(int index) size_t req_size = static_cast(index)+1; if (req_size > __parray_cap_) { - size_t newcap; - const size_t mx = std::numeric_limits::max(); - if (req_size < mx/2) - newcap = _VSTD::max(2 * __parray_cap_, req_size); - else - newcap = mx; - void** parray = (void**)realloc(__parray_, newcap * sizeof(void*)); + size_t newcap = __ios_new_cap(req_size, __iarray_cap_); + void** parray = static_cast(realloc(__parray_, newcap * sizeof(void *))); if (parray == 0) { setstate(badbit); @@ -210,8 +210,9 @@ ios_base::pword(int index) return error; } __parray_ = parray; - for (void** p = __parray_ + __parray_size_; __parray_cap_ < newcap; ++__parray_cap_, ++p) + for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p) *p = 0; + __parray_cap_ = newcap; } __parray_size_ = max(__parray_size_, req_size); return __parray_[index]; @@ -225,20 +226,16 @@ ios_base::register_callback(event_callback fn, int index) size_t req_size = __event_size_ + 1; if (req_size > __event_cap_) { - size_t newcap; - const size_t mx = std::numeric_limits::max(); - if (req_size < mx/2) - newcap = _VSTD::max(2 * __event_cap_, req_size); - else - newcap = mx; - event_callback* fns = (event_callback*)realloc(__fn_, newcap * sizeof(event_callback)); + size_t newcap = __ios_new_cap(req_size, __event_cap_); + event_callback* fns = static_cast(realloc(__fn_, newcap * sizeof(event_callback))); if (fns == 0) setstate(badbit); __fn_ = fns; - int* indxs = (int*)realloc(__index_, newcap * sizeof(int)); + int* indxs = static_cast(realloc(__index_, newcap * sizeof(int))); if (indxs == 0) setstate(badbit); __index_ = indxs; + __event_cap_ = newcap; } __fn_[__event_size_] = fn; __index_[__event_size_] = index; @@ -248,7 +245,7 @@ ios_base::register_callback(event_callback fn, int index) ios_base::~ios_base() { __call_callbacks(erase_event); - locale& loc_storage = *(locale*)&__loc_; + locale& loc_storage = *reinterpret_cast(&__loc_); loc_storage.~locale(); free(__fn_); free(__index_); @@ -299,19 +296,22 @@ void ios_base::copyfmt(const ios_base& rhs) { // If we can't acquire the needed resources, throw bad_alloc (can't set badbit) - // Don't alter *this until all needed resources are aquired + // Don't alter *this until all needed resources are acquired unique_ptr new_callbacks(0, free); unique_ptr new_ints(0, free); unique_ptr new_longs(0, free); unique_ptr new_pointers(0, free); if (__event_cap_ < rhs.__event_size_) { - new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_)); + size_t newesize = sizeof(event_callback) * rhs.__event_size_; + new_callbacks.reset(static_cast(malloc(newesize))); #ifndef _LIBCPP_NO_EXCEPTIONS if (!new_callbacks) throw bad_alloc(); #endif // _LIBCPP_NO_EXCEPTIONS - new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_)); + + size_t newisize = sizeof(int) * rhs.__event_size_; + new_ints.reset(static_cast(malloc(newisize))); #ifndef _LIBCPP_NO_EXCEPTIONS if (!new_ints) throw bad_alloc(); @@ -319,7 +319,8 @@ ios_base::copyfmt(const ios_base& rhs) } if (__iarray_cap_ < rhs.__iarray_size_) { - new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_)); + size_t newsize = sizeof(long) * rhs.__iarray_size_; + new_longs.reset(static_cast(malloc(newsize))); #ifndef _LIBCPP_NO_EXCEPTIONS if (!new_longs) throw bad_alloc(); @@ -327,7 +328,8 @@ ios_base::copyfmt(const ios_base& rhs) } if (__parray_cap_ < rhs.__parray_size_) { - new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_)); + size_t newsize = sizeof(void*) * rhs.__parray_size_; + new_pointers.reset(static_cast(malloc(newsize))); #ifndef _LIBCPP_NO_EXCEPTIONS if (!new_pointers) throw bad_alloc(); @@ -337,8 +339,8 @@ ios_base::copyfmt(const ios_base& rhs) __fmtflags_ = rhs.__fmtflags_; __precision_ = rhs.__precision_; __width_ = rhs.__width_; - locale& lhs_loc = *(locale*)&__loc_; - locale& rhs_loc = *(locale*)&rhs.__loc_; + locale& lhs_loc = *reinterpret_cast(&__loc_); + const locale& rhs_loc = *reinterpret_cast(&rhs.__loc_); lhs_loc = rhs_loc; if (__event_cap_ < rhs.__event_size_) { @@ -381,7 +383,7 @@ ios_base::move(ios_base& rhs) __rdstate_ = rhs.__rdstate_; __exceptions_ = rhs.__exceptions_; __rdbuf_ = 0; - locale& rhs_loc = *(locale*)&rhs.__loc_; + locale& rhs_loc = *reinterpret_cast(&rhs.__loc_); ::new(&__loc_) locale(rhs_loc); __fn_ = rhs.__fn_; rhs.__fn_ = 0; @@ -413,8 +415,8 @@ ios_base::swap(ios_base& rhs) _NOEXCEPT _VSTD::swap(__width_, rhs.__width_); _VSTD::swap(__rdstate_, rhs.__rdstate_); _VSTD::swap(__exceptions_, rhs.__exceptions_); - locale& lhs_loc = *(locale*)&__loc_; - locale& rhs_loc = *(locale*)&rhs.__loc_; + locale& lhs_loc = *reinterpret_cast(&__loc_); + locale& rhs_loc = *reinterpret_cast(&rhs.__loc_); _VSTD::swap(lhs_loc, rhs_loc); _VSTD::swap(__fn_, rhs.__fn_); _VSTD::swap(__index_, rhs.__index_); diff --git a/contrib/libc++/src/locale.cpp b/contrib/libc++/src/locale.cpp index a326323ac..f21e35dd5 100644 --- a/contrib/libc++/src/locale.cpp +++ b/contrib/libc++/src/locale.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; - // On Solaris, we need to define something to make the C99 parts of localeconv // visible. #ifdef __sun__ @@ -30,9 +28,9 @@ #include "__sso_allocator" #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include -#else // _LIBCPP_MSVCRT +#elif !defined(__ANDROID__) #include -#endif // !_LIBCPP_MSVCRT +#endif #include #include @@ -68,7 +66,7 @@ make(A0 a0) { static typename aligned_storage::type buf; ::new (&buf) T(a0); - return *(T*)&buf; + return *reinterpret_cast(&buf); } template @@ -78,7 +76,7 @@ make(A0 a0, A1 a1) { static typename aligned_storage::type buf; ::new (&buf) T(a0, a1); - return *(T*)&buf; + return *reinterpret_cast(&buf); } template @@ -88,7 +86,7 @@ make(A0 a0, A1 a1, A2 a2) { static typename aligned_storage::type buf; ::new (&buf) T(a0, a1, a2); - return *(T*)&buf; + return *reinterpret_cast(&buf); } template @@ -177,7 +175,7 @@ locale::__imp::__imp(size_t refs) facets_.clear(); install(&make<_VSTD::collate >(1u)); install(&make<_VSTD::collate >(1u)); - install(&make<_VSTD::ctype >((ctype_base::mask*)0, false, 1u)); + install(&make<_VSTD::ctype >(nullptr, false, 1u)); install(&make<_VSTD::ctype >(1u)); install(&make >(1u)); install(&make >(1u)); @@ -461,7 +459,7 @@ locale::__imp::make_classic() { // only one thread can get in here and it only gets in once static aligned_storage::type buf; - locale* c = (locale*)&buf; + locale* c = reinterpret_cast(&buf); c->__locale_ = &make<__imp>(1u); return *c; } @@ -479,7 +477,7 @@ locale::__imp::make_global() // only one thread can get in here and it only gets in once static aligned_storage::type buf; ::new (&buf) locale(locale::classic()); - return *(locale*)&buf; + return *reinterpret_cast(&buf); } locale& @@ -1036,7 +1034,9 @@ ctype::classic_table() _NOEXCEPT #elif defined(__EMSCRIPTEN__) return *__ctype_b_loc(); #elif defined(_AIX) - return (const unsigned long *)__lc_ctype_ptr->obj->mask; + return (const unsigned int *)__lc_ctype_ptr->obj->mask; +#elif defined(__ANDROID__) + return reinterpret_cast(_ctype_) + 1; #else // Platform not supported: abort so the person doing the port knows what to // fix @@ -1615,9 +1615,9 @@ int codecvt::do_encoding() const _NOEXCEPT { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS - if (mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0) + if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0) #else - if (__mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0) + if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0) #endif { // stateless encoding @@ -1743,8 +1743,8 @@ utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm return codecvt_base::error; if (to_end-to_nxt < 4) return codecvt_base::partial; - if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) + - (((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode) + if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) + + ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode) return codecvt_base::error; ++frm_nxt; uint8_t z = ((wc1 & 0x03C0) >> 6) + 1; @@ -1820,8 +1820,8 @@ utf16_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm return codecvt_base::error; if (to_end-to_nxt < 4) return codecvt_base::partial; - if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) + - (((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode) + if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) + + ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode) return codecvt_base::error; ++frm_nxt; uint8_t z = ((wc1 & 0x03C0) >> 6) + 1; @@ -1944,9 +1944,9 @@ utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nx return codecvt_base::error; if (to_end-to_nxt < 2) return codecvt_base::partial; - if (((((unsigned long)c1 & 7) << 18) + - (((unsigned long)c2 & 0x3F) << 12) + - (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode) + if ((((c1 & 7UL) << 18) + + ((c2 & 0x3FUL) << 12) + + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode) return codecvt_base::error; *to_nxt = static_cast( 0xD800 @@ -2065,9 +2065,9 @@ utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nx return codecvt_base::error; if (to_end-to_nxt < 2) return codecvt_base::partial; - if (((((unsigned long)c1 & 7) << 18) + - (((unsigned long)c2 & 0x3F) << 12) + - (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode) + if ((((c1 & 7UL) << 18) + + ((c2 & 0x3FUL) << 12) + + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode) return codecvt_base::error; *to_nxt = static_cast( 0xD800 @@ -2174,9 +2174,9 @@ utf8_to_utf16_length(const uint8_t* frm, const uint8_t* frm_end, } if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80) break; - if (((((unsigned long)c1 & 7) << 18) + - (((unsigned long)c2 & 0x3F) << 12) + - (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode) + if ((((c1 & 7UL) << 18) + + ((c2 & 0x3FUL) << 12) + + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode) break; ++nchar16_t; frm_nxt += 4; diff --git a/contrib/libc++/src/memory.cpp b/contrib/libc++/src/memory.cpp index 98bcc864e..8a4eb3481 100644 --- a/contrib/libc++/src/memory.cpp +++ b/contrib/libc++/src/memory.cpp @@ -9,8 +9,10 @@ #define _LIBCPP_BUILDING_MEMORY #include "memory" +#ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" #include "thread" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -109,7 +111,7 @@ __shared_weak_count::lock() _NOEXCEPT return 0; } -#ifndef _LIBCPP_NO_RTTI +#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) const void* __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT @@ -119,7 +121,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT #endif // _LIBCPP_NO_RTTI -#if __has_feature(cxx_atomic) +#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) static const std::size_t __sp_mut_count = 16; static pthread_mutex_t mut_back_imp[__sp_mut_count] = @@ -172,7 +174,7 @@ __get_sp_mut(const void* p) return muts[hash()(p) & (__sp_mut_count-1)]; } -#endif // __has_feature(cxx_atomic) +#endif // __has_feature(cxx_atomic) && !_LIBCPP_HAS_NO_THREADS void declare_reachable(void*) @@ -208,7 +210,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space) if (size <= space) { char* p1 = static_cast(ptr); - char* p2 = (char*)((size_t)(p1 + (alignment - 1)) & -alignment); + char* p2 = reinterpret_cast(reinterpret_cast(p1 + (alignment - 1)) & -alignment); size_t d = static_cast(p2 - p1); if (d <= space - size) { diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp index 07678978a..e56271d30 100644 --- a/contrib/libc++/src/mutex.cpp +++ b/contrib/libc++/src/mutex.cpp @@ -14,6 +14,7 @@ #include "cassert" _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_THREADS const defer_lock_t defer_lock = {}; const try_to_lock_t try_to_lock = {}; @@ -206,18 +207,42 @@ recursive_timed_mutex::unlock() _NOEXCEPT } } +#endif // !_LIBCPP_HAS_NO_THREADS + // If dispatch_once_f ever handles C++ exceptions, and if one can get to it // without illegal macros (unexpected macros not beginning with _UpperCase or // __lowercase), and if it stops spinning waiting threads, then call_once should // call into dispatch_once_f instead of here. Relevant radar this code needs to // keep in sync with: 7741191. +#ifndef _LIBCPP_HAS_NO_THREADS static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cv = PTHREAD_COND_INITIALIZER; +#endif void __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) { +#if defined(_LIBCPP_HAS_NO_THREADS) + if (flag == 0) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + flag = 1; + func(arg); + flag = ~0ul; +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + flag = 0ul; + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS + } +#else // !_LIBCPP_HAS_NO_THREADS pthread_mutex_lock(&mut); while (flag == 1) pthread_cond_wait(&cv, &mut); @@ -248,6 +273,8 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) } else pthread_mutex_unlock(&mut); +#endif // !_LIBCPP_HAS_NO_THREADS + } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/src/new.cpp b/contrib/libc++/src/new.cpp index f4998cfb2..a88d4cc7c 100644 --- a/contrib/libc++/src/new.cpp +++ b/contrib/libc++/src/new.cpp @@ -17,7 +17,7 @@ #define __has_include(inc) 0 #endif -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(LIBCXXRT) #include #ifndef _LIBCPPABI_VERSION @@ -167,7 +167,7 @@ set_new_handler(new_handler handler) _NOEXCEPT new_handler get_new_handler() _NOEXCEPT { - return __sync_fetch_and_add(&__new_handler, (new_handler)0); + return __sync_fetch_and_add(&__new_handler, nullptr); } #endif // !__GLIBCXX__ @@ -192,8 +192,6 @@ bad_alloc::what() const _NOEXCEPT #endif // !__GLIBCXX__ -#endif //LIBCXXRT - bad_array_new_length::bad_array_new_length() _NOEXCEPT { } @@ -202,6 +200,14 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT { } +const char* +bad_array_new_length::what() const _NOEXCEPT +{ + return "bad_array_new_length"; +} + +#endif //LIBCXXRT + const char* bad_array_length::what() const _NOEXCEPT { @@ -216,12 +222,6 @@ bad_array_length::~bad_array_length() _NOEXCEPT { } -const char* -bad_array_new_length::what() const _NOEXCEPT -{ - return "bad_array_new_length"; -} - #endif // _LIBCPPABI_VERSION #ifndef LIBSTDCXX diff --git a/contrib/libc++/src/optional.cpp b/contrib/libc++/src/optional.cpp index b614d8116..8c5dd76d8 100644 --- a/contrib/libc++/src/optional.cpp +++ b/contrib/libc++/src/optional.cpp @@ -9,8 +9,7 @@ #include "experimental/optional" -namespace std // purposefully not using versioning namespace -{ namespace experimental { +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -22,4 +21,4 @@ bad_optional_access::~bad_optional_access() _NOEXCEPT = default; #endif -}} // std::experimental +_LIBCPP_END_NAMESPACE_EXPERIMENTAL diff --git a/contrib/libc++/src/random.cpp b/contrib/libc++/src/random.cpp index bd24f2e50..15ed65b58 100644 --- a/contrib/libc++/src/random.cpp +++ b/contrib/libc++/src/random.cpp @@ -11,23 +11,27 @@ // Must be defined before including stdlib.h to enable rand_s(). #define _CRT_RAND_S #include -#endif +#endif // defined(_WIN32) #include "random" #include "system_error" -#ifdef __sun__ +#if defined(__sun__) #define rename solaris_headers_are_broken -#endif +#endif // defined(__sun__) #if !defined(_WIN32) #include #include -#endif // defined(_WIN32) +#endif // !defined(_WIN32) #include +#if defined(_LIBCPP_USING_NACL_RANDOM) +#include +#endif // defined(_LIBCPP_USING_NACL_RANDOM) _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_WIN32) + random_device::random_device(const string&) { } @@ -45,11 +49,43 @@ random_device::operator()() __throw_system_error(err, "random_device rand_s failed."); return r; } -#else + +#elif defined(_LIBCPP_USING_NACL_RANDOM) + +random_device::random_device(const string& __token) +{ + if (__token != "/dev/urandom") + __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); + int error = nacl_secure_random_init(); + if (error) + __throw_system_error(error, ("random device failed to open " + __token).c_str()); +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + size_t n = sizeof(r); + char* p = reinterpret_cast(&r); + size_t bytes_written; + int error = nacl_secure_random(&r, n, &bytes_written); + if (error != 0) + __throw_system_error(error, "random_device failed getting bytes"); + else if (bytes_written != n) + __throw_runtime_error("random_device failed to obtain enough bytes"); + return r; +} + +#else // !defined(_WIN32) && !defined(_LIBCPP_USING_NACL_RANDOM) + random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { - if (__f_ <= 0) + if (__f_ < 0) __throw_system_error(errno, ("random_device failed to open " + __token).c_str()); } @@ -62,10 +98,26 @@ unsigned random_device::operator()() { unsigned r; - read(__f_, &r, sizeof(r)); + size_t n = sizeof(r); + char* p = reinterpret_cast(&r); + while (n > 0) + { + ssize_t s = read(__f_, p, n); + if (s == 0) + __throw_system_error(ENODATA, "random_device got EOF"); + if (s == -1) + { + if (errno != EINTR) + __throw_system_error(errno, "random_device got an unexpected error"); + continue; + } + n -= static_cast(s); + p += static_cast(s); + } return r; } -#endif // defined(_WIN32) + +#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM) double random_device::entropy() const _NOEXCEPT diff --git a/contrib/libc++/src/regex.cpp b/contrib/libc++/src/regex.cpp index e3ec2810c..17dd6eaa6 100644 --- a/contrib/libc++/src/regex.cpp +++ b/contrib/libc++/src/regex.cpp @@ -69,8 +69,10 @@ regex_error::~regex_error() throw() {} namespace { +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif struct collationnames { @@ -78,7 +80,9 @@ struct collationnames char char_; }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif const collationnames collatenames[] = { @@ -195,16 +199,20 @@ const collationnames collatenames[] = {"zero", 0x30} }; +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif struct classnames { const char* elem_; - ctype_base::mask mask_; + regex_traits::char_class_type mask_; }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif const classnames ClassNames[] = { @@ -246,12 +254,12 @@ __get_collation_name(const char* s) return r; } -ctype_base::mask +regex_traits::char_class_type __get_classname(const char* s, bool __icase) { const classnames* i = _VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp()); - ctype_base::mask r = 0; + regex_traits::char_class_type r = 0; if (i != end(ClassNames) && strcmp(s, i->elem_) == 0) { r = i->mask_; diff --git a/contrib/libc++/src/shared_mutex.cpp b/contrib/libc++/src/shared_mutex.cpp index 5fb22e445..2b78c1feb 100644 --- a/contrib/libc++/src/shared_mutex.cpp +++ b/contrib/libc++/src/shared_mutex.cpp @@ -7,12 +7,15 @@ // //===----------------------------------------------------------------------===// +#include "__config" +#ifndef _LIBCPP_HAS_NO_THREADS + #define _LIBCPP_BUILDING_SHARED_MUTEX #include "shared_mutex" _LIBCPP_BEGIN_NAMESPACE_STD -shared_mutex::shared_mutex() +shared_timed_mutex::shared_timed_mutex() : __state_(0) { } @@ -20,7 +23,7 @@ shared_mutex::shared_mutex() // Exclusive ownership void -shared_mutex::lock() +shared_timed_mutex::lock() { unique_lock lk(__mut_); while (__state_ & __write_entered_) @@ -31,7 +34,7 @@ shared_mutex::lock() } bool -shared_mutex::try_lock() +shared_timed_mutex::try_lock() { unique_lock lk(__mut_); if (__state_ == 0) @@ -43,7 +46,7 @@ shared_mutex::try_lock() } void -shared_mutex::unlock() +shared_timed_mutex::unlock() { lock_guard _(__mut_); __state_ = 0; @@ -53,7 +56,7 @@ shared_mutex::unlock() // Shared ownership void -shared_mutex::lock_shared() +shared_timed_mutex::lock_shared() { unique_lock lk(__mut_); while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) @@ -64,7 +67,7 @@ shared_mutex::lock_shared() } bool -shared_mutex::try_lock_shared() +shared_timed_mutex::try_lock_shared() { unique_lock lk(__mut_); unsigned num_readers = __state_ & __n_readers_; @@ -79,7 +82,7 @@ shared_mutex::try_lock_shared() } void -shared_mutex::unlock_shared() +shared_timed_mutex::unlock_shared() { lock_guard _(__mut_); unsigned num_readers = (__state_ & __n_readers_) - 1; @@ -99,3 +102,5 @@ shared_mutex::unlock_shared() _LIBCPP_END_NAMESPACE_STD + +#endif // !_LIBCPP_HAS_NO_THREADS diff --git a/contrib/libc++/src/stdexcept.cpp b/contrib/libc++/src/stdexcept.cpp index a4207d605..aff4b1850 100644 --- a/contrib/libc++/src/stdexcept.cpp +++ b/contrib/libc++/src/stdexcept.cpp @@ -7,123 +7,42 @@ // //===----------------------------------------------------------------------===// +#include "__refstring" #include "stdexcept" #include "new" #include "string" -#include -#include -#include -#include #include "system_error" #ifndef __has_include #define __has_include(inc) 0 #endif -#ifdef __APPLE__ +/* For _LIBCPPABI_VERSION */ +#if __has_include() || defined(__APPLE_) || defined(LIBCXXRT) #include -#elif defined(LIBCXXRT) || __has_include() -#include -#endif - -// Note: optimize for size - -#if ! defined(_LIBCPP_MSVC) -#pragma GCC visibility push(hidden) #endif -namespace -{ - -class __libcpp_nmstr -{ -private: - const char* str_; - - typedef std::size_t unused_t; - typedef std::ptrdiff_t count_t; - - static const std::ptrdiff_t offset = static_cast(2*sizeof(unused_t) + - sizeof(count_t)); - - count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));} -public: - explicit __libcpp_nmstr(const char* msg); - __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT; - __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT; - ~__libcpp_nmstr(); - const char* c_str() const _NOEXCEPT {return str_;} -}; - -__libcpp_nmstr::__libcpp_nmstr(const char* msg) -{ - std::size_t len = strlen(msg); - str_ = new char[len + 1 + offset]; - unused_t* c = (unused_t*)str_; - c[0] = c[1] = len; - str_ += offset; - count() = 0; - std::memcpy(const_cast(c_str()), msg, len + 1); -} - -inline -__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT - : str_(s.str_) -{ - __sync_add_and_fetch(&count(), 1); -} - -__libcpp_nmstr& -__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT -{ - const char* p = str_; - str_ = s.str_; - __sync_add_and_fetch(&count(), 1); - if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0) - delete [] (p-offset); - return *this; -} - -inline -__libcpp_nmstr::~__libcpp_nmstr() -{ - if (__sync_add_and_fetch(&count(), count_t(-1)) < 0) - delete [] (str_ - offset); -} - -} - -#if ! defined(_LIBCPP_MSVC) -#pragma GCC visibility pop -#endif +static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); namespace std // purposefully not using versioning namespace { -logic_error::logic_error(const string& msg) +logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr(msg.c_str()); } -logic_error::logic_error(const char* msg) +logic_error::logic_error(const char* msg) : __imp_(msg) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr(msg); } -logic_error::logic_error(const logic_error& le) _NOEXCEPT +logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_); } logic_error& logic_error::operator=(const logic_error& le) _NOEXCEPT { - __libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_; - const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_; - s1 = s2; + __imp_ = le.__imp_; return *this; } @@ -131,43 +50,33 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT logic_error::~logic_error() _NOEXCEPT { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - s.~__libcpp_nmstr(); } const char* logic_error::what() const _NOEXCEPT { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - return s.c_str(); + return __imp_.c_str(); } #endif -runtime_error::runtime_error(const string& msg) +runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr(msg.c_str()); } -runtime_error::runtime_error(const char* msg) +runtime_error::runtime_error(const char* msg) : __imp_(msg) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr(msg); } runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT + : __imp_(le.__imp_) { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - ::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_); } runtime_error& runtime_error::operator=(const runtime_error& le) _NOEXCEPT { - __libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_; - const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_; - s1 = s2; + __imp_ = le.__imp_; return *this; } @@ -175,15 +84,12 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT runtime_error::~runtime_error() _NOEXCEPT { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - s.~__libcpp_nmstr(); } const char* runtime_error::what() const _NOEXCEPT { - __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; - return s.c_str(); + return __imp_.c_str(); } domain_error::~domain_error() _NOEXCEPT {} diff --git a/contrib/libc++/src/string.cpp b/contrib/libc++/src/string.cpp index fde52129e..febc53209 100644 --- a/contrib/libc++/src/string.cpp +++ b/contrib/libc++/src/string.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; - #include "string" #include "cstdlib" #include "cwchar" @@ -65,7 +63,7 @@ inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) { - typename S::value_type* ptr; + typename S::value_type* ptr = nullptr; const typename S::value_type* const p = str.c_str(); typename remove_reference::type errno_save = errno; errno = 0; @@ -182,7 +180,7 @@ inline V as_float_helper(const string& func, const S& str, size_t* idx, F f ) { - typename S::value_type* ptr; + typename S::value_type* ptr = nullptr; const typename S::value_type* const p = str.c_str(); typename remove_reference::type errno_save = errno; errno = 0; diff --git a/contrib/libc++/src/strstream.cpp b/contrib/libc++/src/strstream.cpp index c1965ea37..ea728138d 100644 --- a/contrib/libc++/src/strstream.cpp +++ b/contrib/libc++/src/strstream.cpp @@ -61,7 +61,7 @@ strstreambuf::strstreambuf(const char* __gnext, streamsize __n) __palloc_(nullptr), __pfree_(nullptr) { - __init((char*)__gnext, __n, nullptr); + __init(const_cast(__gnext), __n, nullptr); } strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg) @@ -70,7 +70,7 @@ strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __ __palloc_(nullptr), __pfree_(nullptr) { - __init((char*)__gnext, __n, (char*)__pbeg); + __init(const_cast(reinterpret_cast(__gnext)), __n, reinterpret_cast(__pbeg)); } strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n) @@ -79,7 +79,7 @@ strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n) __palloc_(nullptr), __pfree_(nullptr) { - __init((char*)__gnext, __n, nullptr); + __init(const_cast(reinterpret_cast(__gnext)), __n, nullptr); } strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg) @@ -88,7 +88,7 @@ strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char __palloc_(nullptr), __pfree_(nullptr) { - __init((char*)__gnext, __n, (char*)__pbeg); + __init(const_cast(reinterpret_cast(__gnext)), __n, reinterpret_cast(__pbeg)); } strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n) @@ -97,7 +97,7 @@ strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n) __palloc_(nullptr), __pfree_(nullptr) { - __init((char*)__gnext, __n, nullptr); + __init(const_cast(reinterpret_cast(__gnext)), __n, nullptr); } strstreambuf::~strstreambuf() @@ -186,7 +186,7 @@ strstreambuf::overflow(int_type __c) } *pptr() = static_cast(__c); pbump(1); - return int_type((unsigned char)__c); + return int_type(static_cast(__c)); } strstreambuf::int_type @@ -222,7 +222,7 @@ strstreambuf::underflow() return EOF; setg(eback(), gptr(), pptr()); } - return int_type((unsigned char)*gptr()); + return int_type(static_cast(*gptr())); } strstreambuf::pos_type diff --git a/contrib/libc++/src/system_error.cpp b/contrib/libc++/src/system_error.cpp index b40409f85..9c8adc4f3 100644 --- a/contrib/libc++/src/system_error.cpp +++ b/contrib/libc++/src/system_error.cpp @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_BUILDING_SYSTEM_ERROR +#define _LIBCPP_BUILDING_SYSTEM_ERROR +#include "__config" #include "system_error" #include "string" #include "cstring" @@ -65,10 +66,10 @@ __generic_error_category::name() const _NOEXCEPT string __generic_error_category::message(int ev) const { -#ifdef ELAST - if (ev > ELAST) +#ifdef _LIBCPP_ELAST + if (ev > _LIBCPP_ELAST) return string("unspecified generic_category error"); -#endif // ELAST +#endif // _LIBCPP_ELAST return __do_message::message(ev); } @@ -97,20 +98,20 @@ __system_error_category::name() const _NOEXCEPT string __system_error_category::message(int ev) const { -#ifdef ELAST - if (ev > ELAST) +#ifdef _LIBCPP_ELAST + if (ev > _LIBCPP_ELAST) return string("unspecified system_category error"); -#endif // ELAST +#endif // _LIBCPP_ELAST return __do_message::message(ev); } error_condition __system_error_category::default_error_condition(int ev) const _NOEXCEPT { -#ifdef ELAST - if (ev > ELAST) +#ifdef _LIBCPP_ELAST + if (ev > _LIBCPP_ELAST) return error_condition(ev, system_category()); -#endif // ELAST +#endif // _LIBCPP_ELAST return error_condition(ev, generic_category()); } diff --git a/contrib/libc++/src/thread.cpp b/contrib/libc++/src/thread.cpp index 338a8a24c..6aad558ab 100644 --- a/contrib/libc++/src/thread.cpp +++ b/contrib/libc++/src/thread.cpp @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +#include "__config" +#ifndef _LIBCPP_HAS_NO_THREADS + #include "thread" #include "exception" #include "vector" @@ -14,10 +17,10 @@ #include "limits" #include #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) -#include -#endif // !__sun__ && !__linux__ && !_AIX -#include +# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# include +# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# include #endif // !_WIN32 #if defined(__NetBSD__) @@ -121,7 +124,9 @@ sleep_for(const chrono::nanoseconds& ns) ts.tv_sec = ts_sec_max; ts.tv_nsec = giga::num - 1; } - nanosleep(&ts, 0); + + while (nanosleep(&ts, &ts) == -1 && errno == EINTR) + ; } } @@ -144,7 +149,7 @@ class _LIBCPP_HIDDEN __hidden_allocator T* allocate(size_t __n) {return static_cast(::operator new(__n * sizeof(T)));} - void deallocate(T* __p, size_t) {::operator delete((void*)__p);} + void deallocate(T* __p, size_t) {::operator delete(static_cast(__p));} size_t max_size() const {return size_t(~0) / sizeof(T);} }; @@ -223,3 +228,5 @@ __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s) } _LIBCPP_END_NAMESPACE_STD + +#endif // !_LIBCPP_HAS_NO_THREADS diff --git a/contrib/libc++/src/valarray.cpp b/contrib/libc++/src/valarray.cpp index e4c9ed024..2d8db52ac 100644 --- a/contrib/libc++/src/valarray.cpp +++ b/contrib/libc++/src/valarray.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; - #include "valarray" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/contrib/libcxxrt/atomic.h b/contrib/libcxxrt/atomic.h index cfaff3f7d..131ca9f57 100644 --- a/contrib/libcxxrt/atomic.h +++ b/contrib/libcxxrt/atomic.h @@ -11,7 +11,7 @@ */ #if __has_builtin(__c11_atomic_exchange) #define ATOMIC_SWAP(addr, val)\ - __c11_atomic_exchange((_Atomic(__typeof__(val))*)addr, val, __ATOMIC_ACQ_REL) + __c11_atomic_exchange(reinterpret_cast<_Atomic(__typeof__(val))*>(addr), val, __ATOMIC_ACQ_REL) #elif __has_builtin(__sync_swap) #define ATOMIC_SWAP(addr, val)\ __sync_swap(addr, val) @@ -22,7 +22,7 @@ #if __has_builtin(__c11_atomic_load) #define ATOMIC_LOAD(addr)\ - __c11_atomic_load((_Atomic(__typeof__(*addr))*)addr, __ATOMIC_ACQUIRE) + __c11_atomic_load(reinterpret_cast<_Atomic(__typeof__(*addr))*>(addr), __ATOMIC_ACQUIRE) #else #define ATOMIC_LOAD(addr)\ (__sync_synchronize(), *addr) diff --git a/contrib/libcxxrt/auxhelper.cc b/contrib/libcxxrt/auxhelper.cc index 213f8a089..3e98da036 100644 --- a/contrib/libcxxrt/auxhelper.cc +++ b/contrib/libcxxrt/auxhelper.cc @@ -75,3 +75,8 @@ extern "C" void __cxa_deleted_virtual() { abort(); } + +extern "C" void __cxa_throw_bad_array_new_length() +{ + throw std::bad_array_new_length(); +} diff --git a/contrib/libcxxrt/cxxabi.h b/contrib/libcxxrt/cxxabi.h index 7c8336076..411c4c749 100644 --- a/contrib/libcxxrt/cxxabi.h +++ b/contrib/libcxxrt/cxxabi.h @@ -110,7 +110,7 @@ struct __cxa_exception * handler count reaches 0 (which it doesn't with the top bit set). */ int handlerCount; -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) /** * The ARM EH ABI requires the unwind library to keep track of exceptions * during cleanups. These support nesting, so we need to keep a list of diff --git a/contrib/libcxxrt/dwarf_eh.h b/contrib/libcxxrt/dwarf_eh.h index d5e1e2847..af533b346 100644 --- a/contrib/libcxxrt/dwarf_eh.h +++ b/contrib/libcxxrt/dwarf_eh.h @@ -83,7 +83,7 @@ enum dwarf_data_encoding */ static inline enum dwarf_data_encoding get_encoding(unsigned char x) { - return (enum dwarf_data_encoding)(x & 0xf); + return static_cast(x & 0xf); } /** @@ -115,7 +115,7 @@ enum dwarf_data_relative */ static inline enum dwarf_data_relative get_base(unsigned char x) { - return (enum dwarf_data_relative)(x & 0x70); + return static_cast(x & 0x70); } /** * Returns whether an encoding represents an indirect address. @@ -206,9 +206,9 @@ static int64_t read_sleb128(dw_eh_ptr_t *data) if ((uleb >> (bits-1)) == 1) { // Sign extend by setting all bits in front of it to 1 - uleb |= ((int64_t)-1) << bits; + uleb |= static_cast(-1) << bits; } - return (int64_t)uleb; + return static_cast(uleb); } /** * Reads a value using the specified encoding from the address pointed to by @@ -224,7 +224,7 @@ static uint64_t read_value(char encoding, dw_eh_ptr_t *data) // Read fixed-length types #define READ(dwarf, type) \ case dwarf:\ - v = (uint64_t)(*(type*)(*data));\ + v = static_cast(*reinterpret_cast(*data));\ *data += sizeof(type);\ break; READ(DW_EH_PE_udata2, uint16_t) @@ -263,16 +263,16 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c, switch (get_base(encoding)) { case DW_EH_PE_pcrel: - v += (uint64_t)start; + v += reinterpret_cast(start); break; case DW_EH_PE_textrel: - v += (uint64_t)_Unwind_GetTextRelBase(c); + v += static_cast(static_cast(_Unwind_GetTextRelBase(c))); break; case DW_EH_PE_datarel: - v += (uint64_t)_Unwind_GetDataRelBase(c); + v += static_cast(static_cast(_Unwind_GetDataRelBase(c))); break; case DW_EH_PE_funcrel: - v += (uint64_t)_Unwind_GetRegionStart(c); + v += static_cast(static_cast(_Unwind_GetRegionStart(c))); default: break; } @@ -282,7 +282,7 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c, // be a GCC extensions, so not properly documented... if (is_indirect(encoding)) { - v = (uint64_t)(uintptr_t)*(void**)v; + v = static_cast(reinterpret_cast(*reinterpret_cast(v))); } return v; } @@ -342,14 +342,14 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context, { struct dwarf_eh_lsda lsda; - lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context); + lsda.region_start = reinterpret_cast(_Unwind_GetRegionStart(context)); // If the landing pads are relative to anything other than the start of // this region, find out where. This is @LPStart in the spec, although the // encoding that GCC uses does not quite match the spec. - uint64_t v = (uint64_t)(uintptr_t)lsda.region_start; + uint64_t v = static_cast(reinterpret_cast(lsda.region_start)); read_value_with_encoding(context, &data, &v); - lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v; + lsda.landing_pads = reinterpret_cast(static_cast(v)); // If there is a type table, find out where it is. This is @TTBase in the // spec. Note: we find whether there is a type table pointer by checking @@ -365,18 +365,18 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context, lsda.type_table = type_table; //lsda.type_table = (uintptr_t*)(data + v); } -#if __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect); #endif - lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++)); + lsda.callsite_encoding = static_cast(*(data++)); // Action table is immediately after the call site table lsda.action_table = data; - uintptr_t callsite_size = (uintptr_t)read_uleb128(&data); + uintptr_t callsite_size = static_cast(read_uleb128(&data)); lsda.action_table = data + callsite_size; // Call site table is immediately after the header - lsda.call_site_table = (dw_eh_ptr_t)data; + lsda.call_site_table = static_cast(data); return lsda; @@ -413,7 +413,7 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context, result->landing_pad = 0; // The current instruction pointer offset within the region uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context); - unsigned char *callsite_table = (unsigned char*)lsda->call_site_table; + unsigned char *callsite_table = static_cast(lsda->call_site_table); while (callsite_table <= lsda->action_table) { @@ -463,17 +463,17 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context, /// Defines an exception class from 8 bytes (endian independent) #define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ - (((uint64_t)a << 56) +\ - ((uint64_t)b << 48) +\ - ((uint64_t)c << 40) +\ - ((uint64_t)d << 32) +\ - ((uint64_t)e << 24) +\ - ((uint64_t)f << 16) +\ - ((uint64_t)g << 8) +\ - ((uint64_t)h)) + ((static_cast(a) << 56) +\ + (static_cast(b) << 48) +\ + (static_cast(c) << 40) +\ + (static_cast(d) << 32) +\ + (static_cast(e) << 24) +\ + (static_cast(f) << 16) +\ + (static_cast(g) << 8) +\ + (static_cast(h))) #define GENERIC_EXCEPTION_CLASS(e,f,g,h) \ - ((uint32_t)e << 24) +\ - ((uint32_t)f << 16) +\ - ((uint32_t)g << 8) +\ - ((uint32_t)h) + (static_cast(e) << 24) +\ + (static_cast(f) << 16) +\ + (static_cast(g) << 8) +\ + (static_cast(h)) diff --git a/contrib/libcxxrt/dynamic_cast.cc b/contrib/libcxxrt/dynamic_cast.cc index 7a07e4c6a..6ae3a4035 100644 --- a/contrib/libcxxrt/dynamic_cast.cc +++ b/contrib/libcxxrt/dynamic_cast.cc @@ -44,7 +44,7 @@ struct vtable_header * Simple macro that does pointer arithmetic in bytes but returns a value of * the same type as the original. */ -#define ADD_TO_PTR(x, off) (__typeof__(x))(((char*)x) + off) +#define ADD_TO_PTR(x, off) reinterpret_cast<__typeof__(x)>(reinterpret_cast(x) + off) bool std::type_info::__do_catch(std::type_info const *ex_type, void **exception_object, @@ -166,7 +166,7 @@ bool __vmi_class_type_info::__do_upcast(const __class_type_info *target, if (info->isVirtual()) { // Object's vtable - ptrdiff_t *off = *(ptrdiff_t**)obj; + ptrdiff_t *off = *static_cast(obj); // Offset location in vtable off = ADD_TO_PTR(off, offset); offset = *off; @@ -202,9 +202,9 @@ extern "C" void* __dynamic_cast(const void *sub, const __class_type_info *dst, ptrdiff_t src2dst_offset) { - char *vtable_location = *(char**)sub; + const char *vtable_location = *static_cast(sub); const vtable_header *header = - (const vtable_header*)(vtable_location - sizeof(vtable_header)); - void *leaf = ADD_TO_PTR((void*)sub, header->leaf_offset); + reinterpret_cast(vtable_location - sizeof(vtable_header)); + void *leaf = ADD_TO_PTR(const_cast(sub), header->leaf_offset); return header->type->cast_to(leaf, dst); } diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc index d84890599..e428773cf 100644 --- a/contrib/libcxxrt/exception.cc +++ b/contrib/libcxxrt/exception.cc @@ -71,11 +71,11 @@ static void saveLandingPad(struct _Unwind_Context *context, int selector, dw_eh_ptr_t landingPad) { -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) // On ARM, we store the saved exception in the generic part of the structure ucb->barrier_cache.sp = _Unwind_GetGR(context, 13); - ucb->barrier_cache.bitpattern[1] = (uint32_t)selector; - ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad; + ucb->barrier_cache.bitpattern[1] = static_cast(selector); + ucb->barrier_cache.bitpattern[3] = reinterpret_cast(landingPad); #endif // Cache the results for the phase 2 unwind, if we found a handler // and this is not a foreign exception. @@ -95,15 +95,15 @@ static int loadLandingPad(struct _Unwind_Context *context, unsigned long *selector, dw_eh_ptr_t *landingPad) { -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) *selector = ucb->barrier_cache.bitpattern[1]; - *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3]; + *landingPad = reinterpret_cast(ucb->barrier_cache.bitpattern[3]); return 1; #else if (ex) { *selector = ex->handlerSwitchValue; - *landingPad = (dw_eh_ptr_t)ex->catchTemp; + *landingPad = reinterpret_cast(ex->catchTemp); return 0; } return 0; @@ -113,7 +113,7 @@ static int loadLandingPad(struct _Unwind_Context *context, static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex, struct _Unwind_Context *context) { -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; } #endif return _URC_CONTINUE_UNWIND; @@ -204,7 +204,7 @@ struct __cxa_dependent_exception terminate_handler terminateHandler; __cxa_exception *nextException; int handlerCount; -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) _Unwind_Exception *nextCleanup; int cleanupCount; #endif @@ -267,13 +267,13 @@ static bool isDependentException(uint64_t cls) static __cxa_exception *exceptionFromPointer(void *ex) { - return (__cxa_exception*)((char*)ex - + return reinterpret_cast<__cxa_exception*>(static_cast(ex) - offsetof(struct __cxa_exception, unwindHeader)); } static __cxa_exception *realExceptionFromException(__cxa_exception *ex) { if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; } - return ((__cxa_exception*)(((__cxa_dependent_exception*)ex)->primaryException))-1; + return reinterpret_cast<__cxa_exception*>((reinterpret_cast<__cxa_dependent_exception*>(ex))->primaryException)-1; } @@ -304,13 +304,13 @@ static pthread_key_t eh_key; static void exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_exception((void*)ex); + __cxa_free_exception(static_cast(ex)); } static void dependent_exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_dependent_exception((void*)ex); + __cxa_free_dependent_exception(static_cast(ex)); } /** @@ -333,13 +333,13 @@ static void free_exception_list(__cxa_exception *ex) */ static void thread_cleanup(void* thread_info) { - __cxa_thread_info *info = (__cxa_thread_info*)thread_info; + __cxa_thread_info *info = static_cast<__cxa_thread_info*>(thread_info); if (info->globals.caughtExceptions) { // If this is a foreign exception, ask it to clean itself up. if (info->foreign_exception_state != __cxa_thread_info::none) { - _Unwind_Exception *e = (_Unwind_Exception*)info->globals.caughtExceptions; + _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } else @@ -379,8 +379,8 @@ static void init_key(void) return; } pthread_key_create(&eh_key, thread_cleanup); - pthread_setspecific(eh_key, (void*)0x42); - fakeTLS = (pthread_getspecific(eh_key) != (void*)0x42); + pthread_setspecific(eh_key, reinterpret_cast(0x42)); + fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast(0x42)); pthread_setspecific(eh_key, 0); } @@ -394,10 +394,10 @@ static __cxa_thread_info *thread_info() fakeTLS = true; } if (fakeTLS) { return &singleThreadInfo; } - __cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key); + __cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); if (0 == info) { - info = (__cxa_thread_info*)calloc(1, sizeof(__cxa_thread_info)); + info = static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info))); pthread_setspecific(eh_key, info); } return info; @@ -409,7 +409,7 @@ static __cxa_thread_info *thread_info() static __cxa_thread_info *thread_info_fast() { if (fakeTLS) { return &singleThreadInfo; } - return (__cxa_thread_info*)pthread_getspecific(eh_key); + return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); } /** * ABI function returning the __cxa_eh_globals structure. @@ -472,7 +472,7 @@ static char *emergency_malloc(size_t size) if (0 != m) { pthread_mutex_unlock(&emergency_malloc_lock); - return (char*)m; + return static_cast(m); } for (int i=0 ; i<16 ; i++) { @@ -510,7 +510,7 @@ static void emergency_malloc_free(char *ptr) // Find the buffer corresponding to this pointer. for (int i=0 ; i<16 ; i++) { - if (ptr == (void*)(emergency_buffer + (1024 * i))) + if (ptr == static_cast(emergency_buffer + (1024 * i))) { buffer = i; break; @@ -521,7 +521,7 @@ static void emergency_malloc_free(char *ptr) // emergency_malloc() is expected to return 0-initialized data. We don't // zero the buffer when allocating it, because the static buffers will // begin life containing 0 values. - memset((void*)ptr, 0, 1024); + memset(ptr, 0, 1024); // Signal the condition variable to wake up any threads that are blocking // waiting for some space in the emergency buffer pthread_mutex_lock(&emergency_malloc_lock); @@ -535,7 +535,7 @@ static void emergency_malloc_free(char *ptr) static char *alloc_or_die(size_t size) { - char *buffer = (char*)calloc(1, size); + char *buffer = static_cast(calloc(1, size)); // If calloc() doesn't want to give us any memory, try using an emergency // buffer. @@ -597,7 +597,7 @@ extern "C" void *__cxa_allocate_dependent_exception(void) */ extern "C" void __cxa_free_exception(void *thrown_exception) { - __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1; // Free the object that was thrown, calling its destructor if (0 != ex->exceptionDestructor) { @@ -612,7 +612,7 @@ extern "C" void __cxa_free_exception(void *thrown_exception) } } - free_exception((char*)ex); + free_exception(reinterpret_cast(ex)); } static void releaseException(__cxa_exception *exception) @@ -633,13 +633,13 @@ static void releaseException(__cxa_exception *exception) void __cxa_free_dependent_exception(void *thrown_exception) { - __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)thrown_exception) - 1; + __cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(thrown_exception) - 1; assert(isDependentException(ex->unwindHeader.exception_class)); if (ex->primaryException) { - releaseException(realExceptionFromException((__cxa_exception*)ex)); + releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex))); } - free_exception((char*)ex); + free_exception(reinterpret_cast(ex)); } /** @@ -654,8 +654,8 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) { Dl_info myinfo; int mylookup = - dladdr((void*)(uintptr_t)__cxa_current_exception_type, &myinfo); - void *ip = (void*)_Unwind_GetIP(context); + dladdr(reinterpret_cast(__cxa_current_exception_type), &myinfo); + void *ip = reinterpret_cast(_Unwind_GetIP(context)); Dl_info info; if (dladdr(ip, &info) != 0) { @@ -673,6 +673,11 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) * If the failure happened by falling off the end of the stack without finding * a handler, prints a back trace before aborting. */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +extern "C" void *__cxa_begin_catch(void *e) throw(); +#else +extern "C" void *__cxa_begin_catch(void *e); +#endif static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exception) { switch (err) @@ -681,14 +686,16 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce case _URC_FATAL_PHASE1_ERROR: fprintf(stderr, "Fatal error during phase 1 unwinding\n"); break; -#ifndef __arm__ +#if !defined(__arm__) || defined(__ARM_DWARF_EH__) case _URC_FATAL_PHASE2_ERROR: fprintf(stderr, "Fatal error during phase 2 unwinding\n"); break; #endif case _URC_END_OF_STACK: + __cxa_begin_catch (&(thrown_exception->unwindHeader)); + std::terminate(); fprintf(stderr, "Terminating due to uncaught exception %p", - (void*)thrown_exception); + static_cast(thrown_exception)); thrown_exception = realExceptionFromException(thrown_exception); static const __class_type_info *e_ti = static_cast(&typeid(std::exception)); @@ -697,8 +704,8 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce if (throw_ti) { std::exception *e = - (std::exception*)e_ti->cast_to((void*)(thrown_exception+1), - throw_ti); + static_cast(e_ti->cast_to(static_cast(thrown_exception+1), + throw_ti)); if (e) { fprintf(stderr, " '%s'", e->what()); @@ -706,18 +713,21 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce } size_t bufferSize = 128; - char *demangled = (char*)malloc(bufferSize); + char *demangled = static_cast(malloc(bufferSize)); const char *mangled = thrown_exception->exceptionType->name(); int status; demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status); fprintf(stderr, " of type %s\n", - status == 0 ? (const char*)demangled : mangled); + status == 0 ? demangled : mangled); if (status == 0) { free(demangled); } // Print a back trace if no handler is found. // TODO: Make this optional #ifndef __arm__ _Unwind_Backtrace(trace, 0); #endif + + // Just abort. No need to call std::terminate for the second time + abort(); break; } std::terminate(); @@ -755,7 +765,7 @@ extern "C" void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void(*dest)(void*)) { - __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1; ex->referenceCount = 1; ex->exceptionType = tinfo; @@ -773,7 +783,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception) if (NULL == thrown_exception) { return; } __cxa_exception *original = exceptionFromPointer(thrown_exception); - __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)__cxa_allocate_dependent_exception())-1; + __cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(__cxa_allocate_dependent_exception())-1; ex->primaryException = thrown_exception; __cxa_increment_exception_refcount(thrown_exception); @@ -782,7 +792,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception) ex->unwindHeader.exception_class = dependent_exception_class; ex->unwindHeader.exception_cleanup = dependent_exception_cleanup; - throw_exception((__cxa_exception*)ex); + throw_exception(reinterpret_cast<__cxa_exception*>(ex)); } extern "C" void *__cxa_current_primary_exception(void) @@ -799,14 +809,14 @@ extern "C" void *__cxa_current_primary_exception(void) extern "C" void __cxa_increment_exception_refcount(void* thrown_exception) { if (NULL == thrown_exception) { return; } - __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + __cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1; if (isDependentException(ex->unwindHeader.exception_class)) { return; } __sync_fetch_and_add(&ex->referenceCount, 1); } extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception) { if (NULL == thrown_exception) { return; } - __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + __cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1; releaseException(ex); } @@ -838,7 +848,7 @@ extern "C" void __cxa_rethrow() if (ti->foreign_exception_state != __cxa_thread_info::none) { ti->foreign_exception_state = __cxa_thread_info::rethrown; - _Unwind_Exception *e = (_Unwind_Exception*)ex; + _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ex); _Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e); report_failure(err, ex); return; @@ -881,8 +891,8 @@ static std::type_info *get_type_info_entry(_Unwind_Context *context, if (offset == 0) { return 0; } // ...so we need to resolve it - return (std::type_info*)resolve_indirect_value(context, - lsda->type_table_encoding, offset, start); + return reinterpret_cast(resolve_indirect_value(context, + lsda->type_table_encoding, offset, start)); } @@ -896,13 +906,13 @@ static bool check_type_signature(__cxa_exception *ex, const std::type_info *type, void *&adjustedPtr) { - void *exception_ptr = (void*)(ex+1); + void *exception_ptr = static_cast(ex+1); const std::type_info *ex_type = ex ? ex->exceptionType : 0; bool is_ptr = ex ? ex_type->__is_pointer_p() : false; if (is_ptr) { - exception_ptr = *(void**)exception_ptr; + exception_ptr = *static_cast(exception_ptr); } // Always match a catchall, even with a foreign exception // @@ -974,7 +984,7 @@ static handler_type check_action_record(_Unwind_Context *context, { bool matched = false; *selector = filter; -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) filter++; std::type_info *handler_type = get_type_info_entry(context, lsda, filter--); while (handler_type) @@ -987,7 +997,7 @@ static handler_type check_action_record(_Unwind_Context *context, handler_type = get_type_info_entry(context, lsda, filter--); } #else - unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1); + unsigned char *type_index = reinterpret_cast(lsda->type_table) - filter - 1; while (*type_index) { std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++)); @@ -1019,7 +1029,7 @@ static handler_type check_action_record(_Unwind_Context *context, static void pushCleanupException(_Unwind_Exception *exceptionObject, __cxa_exception *ex) { -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) __cxa_thread_info *info = thread_info_fast(); if (ex) { @@ -1064,8 +1074,13 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) realEx = realExceptionFromException(ex); } +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) + unsigned char *lsda_addr = + static_cast(_Unwind_GetLanguageSpecificData(context)); +#else unsigned char *lsda_addr = - (unsigned char*)_Unwind_GetLanguageSpecificData(context); + reinterpret_cast(static_cast(_Unwind_GetLanguageSpecificData(context))); +#endif // No LSDA implies no landing pads - try the next frame if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); } @@ -1114,8 +1129,8 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) if (ex) { saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad); - ex->languageSpecificData = (const char*)lsda_addr; - ex->actionRecord = (const char*)action.action_record; + ex->languageSpecificData = reinterpret_cast(lsda_addr); + ex->actionRecord = reinterpret_cast(action.action_record); // ex->adjustedPtr is set when finding the action record. } return _URC_HANDLER_FOUND; @@ -1161,9 +1176,9 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) } - _Unwind_SetIP(context, (unsigned long)action.landing_pad); + _Unwind_SetIP(context, reinterpret_cast(action.landing_pad)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), - (unsigned long)exceptionObject); + reinterpret_cast(exceptionObject)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector); return _URC_INSTALL_CONTEXT; @@ -1176,7 +1191,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) * pointer to the caught exception, which is either the adjusted pointer (for * C++ exceptions) of the unadjusted pointer (for foreign exceptions). */ -#if __GNUC__ > 3 && __GNUC_MINOR__ > 2 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) extern "C" void *__cxa_begin_catch(void *e) throw() #else extern "C" void *__cxa_begin_catch(void *e) @@ -1187,7 +1202,7 @@ extern "C" void *__cxa_begin_catch(void *e) __cxa_thread_info *ti = thread_info(); __cxa_eh_globals *globals = &ti->globals; globals->uncaughtExceptions--; - _Unwind_Exception *exceptionObject = (_Unwind_Exception*)e; + _Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(e); if (isCXXException(exceptionObject->exception_class)) { @@ -1241,12 +1256,12 @@ extern "C" void *__cxa_begin_catch(void *e) { std::terminate(); } - globals->caughtExceptions = (__cxa_exception*)exceptionObject; + globals->caughtExceptions = reinterpret_cast<__cxa_exception*>(exceptionObject); ti->foreign_exception_state = __cxa_thread_info::caught; } // exceptionObject is the pointer to the _Unwind_Exception within the // __cxa_exception. The throw object is after this - return ((char*)exceptionObject + sizeof(_Unwind_Exception)); + return (reinterpret_cast(exceptionObject) + sizeof(_Unwind_Exception)); } @@ -1270,7 +1285,7 @@ extern "C" void __cxa_end_catch() globals->caughtExceptions = 0; if (ti->foreign_exception_state != __cxa_thread_info::rethrown) { - _Unwind_Exception *e = (_Unwind_Exception*)ti->globals.caughtExceptions; + _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } ti->foreign_exception_state = __cxa_thread_info::none; @@ -1332,7 +1347,7 @@ extern "C" std::type_info *__cxa_current_exception_type() */ extern "C" void __cxa_call_unexpected(void*exception) { - _Unwind_Exception *exceptionObject = (_Unwind_Exception*)exception; + _Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(exception); if (exceptionObject->exception_class == exception_class) { __cxa_exception *ex = exceptionFromPointer(exceptionObject); @@ -1483,7 +1498,7 @@ namespace std return ATOMIC_LOAD(&terminateHandler); } } -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) extern "C" _Unwind_Exception *__cxa_get_cleanup(void) { __cxa_thread_info *info = thread_info_fast(); diff --git a/contrib/libcxxrt/guard.cc b/contrib/libcxxrt/guard.cc index f0c26ab91..f1c4c69fa 100644 --- a/contrib/libcxxrt/guard.cc +++ b/contrib/libcxxrt/guard.cc @@ -70,18 +70,45 @@ #ifdef __arm__ // ARM ABI - 32-bit guards. typedef uint32_t guard_t; -static const uint32_t LOCKED = ((guard_t)1) << 31; +typedef uint32_t guard_lock_t; +static const uint32_t LOCKED = static_cast(1) << 31; static const uint32_t INITIALISED = 1; -#else +#define LOCK_PART(guard) (guard) +#define INIT_PART(guard) (guard) +#elif defined(_LP64) typedef uint64_t guard_t; +typedef uint64_t guard_lock_t; # if defined(__LITTLE_ENDIAN__) -static const guard_t LOCKED = ((guard_t)1) << 63; +static const guard_t LOCKED = static_cast(1) << 63; static const guard_t INITIALISED = 1; # else static const guard_t LOCKED = 1; -static const guard_t INITIALISED = ((guard_t)1) << 56; +static const guard_t INITIALISED = static_cast(1) << 56; +# endif +#define LOCK_PART(guard) (guard) +#define INIT_PART(guard) (guard) +#else +typedef uint32_t guard_lock_t; +# if defined(__LITTLE_ENDIAN__) +typedef struct { + uint32_t init_half; + uint32_t lock_half; +} guard_t; +static const uint32_t LOCKED = static_cast(1) << 31; +static const uint32_t INITIALISED = 1; +# else +typedef struct { + uint32_t init_half; + uint32_t lock_half; +} guard_t; +_Static_assert(sizeof(guard_t) == sizeof(uint64_t), ""); +static const uint32_t LOCKED = 1; +static const uint32_t INITIALISED = static_cast(1) << 24; # endif +#define LOCK_PART(guard) (&(guard)->lock_half) +#define INIT_PART(guard) (&(guard)->init_half) #endif +static const guard_lock_t INITIAL = 0; /** * Acquires a lock on a guard, returning 0 if the object has already been @@ -90,42 +117,49 @@ static const guard_t INITIALISED = ((guard_t)1) << 56; */ extern "C" int __cxa_guard_acquire(volatile guard_t *guard_object) { + guard_lock_t old; // Not an atomic read, doesn't establish a happens-before relationship, but // if one is already established and we end up seeing an initialised state // then it's a fast path, otherwise we'll do something more expensive than // this test anyway... - if ((INITIALISED == *guard_object)) { return 0; } + if (INITIALISED == *INIT_PART(guard_object)) + return 0; // Spin trying to do the initialisation - while (1) + for (;;) { // Loop trying to move the value of the guard from 0 (not // locked, not initialised) to the locked-uninitialised // position. - switch (__sync_val_compare_and_swap(guard_object, 0, LOCKED)) - { - // If the old value was 0, we succeeded, so continue - // initialising - case 0: + old = __sync_val_compare_and_swap(LOCK_PART(guard_object), + INITIAL, LOCKED); + if (old == INITIAL) { + // Lock obtained. If lock and init bit are + // in separate words, check for init race. + if (INIT_PART(guard_object) == LOCK_PART(guard_object)) return 1; - // If this was already initialised, return and let the caller skip - // initialising it again. - case INITIALISED: - return 0; - // If it is locked by another thread, relinquish the CPU and try - // again later. - case LOCKED: - case LOCKED | INITIALISED: - sched_yield(); - break; - // If it is some other value, then something has gone badly wrong. - // Give up. - default: - fprintf(stderr, "Invalid state detected attempting to lock static initialiser.\n"); - abort(); + if (INITIALISED != *INIT_PART(guard_object)) + return 1; + + // No need for a memory barrier here, + // see first comment. + *LOCK_PART(guard_object) = INITIAL; + return 0; } + // If lock and init bit are in the same word, check again + // if we are done. + if (INIT_PART(guard_object) == LOCK_PART(guard_object) && + old == INITIALISED) + return 0; + + assert(old == LOCKED); + // Another thread holds the lock. + // If lock and init bit are in different words, check + // if we are done before yielding and looping. + if (INIT_PART(guard_object) != LOCK_PART(guard_object) && + INITIALISED == *INIT_PART(guard_object)) + return 0; + sched_yield(); } - //__builtin_unreachable(); - return 0; } /** @@ -135,7 +169,8 @@ extern "C" int __cxa_guard_acquire(volatile guard_t *guard_object) extern "C" void __cxa_guard_abort(volatile guard_t *guard_object) { __attribute__((unused)) - bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, 0); + bool reset = __sync_bool_compare_and_swap(LOCK_PART(guard_object), + LOCKED, INITIAL); assert(reset); } /** @@ -144,9 +179,15 @@ extern "C" void __cxa_guard_abort(volatile guard_t *guard_object) */ extern "C" void __cxa_guard_release(volatile guard_t *guard_object) { + guard_lock_t old; + if (INIT_PART(guard_object) == LOCK_PART(guard_object)) + old = LOCKED; + else + old = INITIAL; __attribute__((unused)) - bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, INITIALISED); + bool reset = __sync_bool_compare_and_swap(INIT_PART(guard_object), + old, INITIALISED); assert(reset); + if (INIT_PART(guard_object) != LOCK_PART(guard_object)) + *LOCK_PART(guard_object) = INITIAL; } - - diff --git a/contrib/libcxxrt/stdexcept.cc b/contrib/libcxxrt/stdexcept.cc index 687fc5e75..c1cea39f6 100644 --- a/contrib/libcxxrt/stdexcept.cc +++ b/contrib/libcxxrt/stdexcept.cc @@ -82,5 +82,18 @@ const char* bad_typeid::what() const throw() return "std::bad_typeid"; } +bad_array_new_length::bad_array_new_length() throw() {} +bad_array_new_length::~bad_array_new_length() {} +bad_array_new_length::bad_array_new_length(const bad_array_new_length&) throw() {} +bad_array_new_length& bad_array_new_length::operator=(const bad_array_new_length&) throw() +{ + return *this; +} + +const char* bad_array_new_length::what() const throw() +{ + return "std::bad_array_new_length"; +} + } // namespace std diff --git a/contrib/libcxxrt/stdexcept.h b/contrib/libcxxrt/stdexcept.h index 49eaf55c3..892039357 100644 --- a/contrib/libcxxrt/stdexcept.h +++ b/contrib/libcxxrt/stdexcept.h @@ -81,6 +81,15 @@ namespace std virtual const char* what() const throw(); }; + class bad_array_new_length: public bad_alloc + { + public: + bad_array_new_length() throw(); + bad_array_new_length(const bad_array_new_length&) throw(); + bad_array_new_length& operator=(const bad_array_new_length&) throw(); + virtual ~bad_array_new_length(); + virtual const char *what() const throw(); + }; } // namespace std diff --git a/contrib/libcxxrt/typeinfo.cc b/contrib/libcxxrt/typeinfo.cc index fda5196e3..71de9ae59 100644 --- a/contrib/libcxxrt/typeinfo.cc +++ b/contrib/libcxxrt/typeinfo.cc @@ -96,7 +96,7 @@ extern "C" char* __cxa_demangle(const char* mangled_name, } if (*n < len+1) { - buf = (char*)realloc(buf, len+1); + buf = static_cast(realloc(buf, len+1)); } if (0 != buf) { diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h index 8c1fa1626..52e563e41 100644 --- a/contrib/libcxxrt/unwind-arm.h +++ b/contrib/libcxxrt/unwind-arm.h @@ -218,6 +218,6 @@ _Unwind_Reason_Code name(_Unwind_State state,\ break;\ }\ }\ - _Unwind_SetGR (context, 12, (unsigned long)exceptionObject);\ + _Unwind_SetGR (context, 12, reinterpret_cast(exceptionObject));\ #define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context) diff --git a/contrib/libcxxrt/unwind.h b/contrib/libcxxrt/unwind.h index e463a2a78..130dd6d82 100644 --- a/contrib/libcxxrt/unwind.h +++ b/contrib/libcxxrt/unwind.h @@ -27,7 +27,7 @@ extern "C" { #endif -#ifdef __arm__ +#if defined(__arm__) && !defined(__ARM_DWARF_EH__) #include "unwind-arm.h" #else #include "unwind-itanium.h" diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index 1e7dfafe4..a499b6928 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + LIBCXXRTDIR= ${.CURDIR}/../../contrib/libcxxrt HDRDIR= ${.CURDIR}/../../contrib/libc++/include SRCDIR= ${.CURDIR}/../../contrib/libc++/src @@ -57,7 +59,7 @@ cxxrt_${_S}: WARNS= 0 CFLAGS+= -I${HDRDIR} -I${LIBCXXRTDIR} -nostdlib -DLIBCXXRT .if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++0x +CXXFLAGS+= -std=c++11 .endif DPADD= ${LIBCXXRT} @@ -74,6 +76,7 @@ STD_HEADERS= __bit_reference\ __hash_table\ __locale\ __mutex_base\ + __refstring\ __split_buffer\ __sso_allocator\ __std_stream\ @@ -175,8 +178,12 @@ STD+= ${LIBCXXRTDIR}/${hdr} .endfor STDDIR= ${CXXINCLUDEDIR} -EXP_HEADERS= dynarray\ - optional +EXP_HEADERS= __config\ + dynarray\ + optional\ + string_view\ + type_traits\ + utility .for hdr in ${EXP_HEADERS} EXP+= ${HDRDIR}/experimental/${hdr} @@ -192,4 +199,14 @@ EXT+= ${HDRDIR}/ext/${hdr} .endfor EXTDIR= ${CXXINCLUDEDIR}/ext +.if ${MK_GNUCXX} == "no" && ${COMPILER_TYPE} == "gcc" +CLEANFILES+= libstdc++.so libstdc++.a + +afterinstall: + ln -sf ${DESTDIR}${LIBDIR}/lib${LIB}.so \ + ${.OBJDIR}/libstdc++.so + ln -sf ${DESTDIR}${LIBDIR}/lib${LIB}.a \ + ${.OBJDIR}/libstdc++.a +.endif + .include diff --git a/lib/libcxxrt/Version.map b/lib/libcxxrt/Version.map index a97c66fe8..b9e4cf90e 100644 --- a/lib/libcxxrt/Version.map +++ b/lib/libcxxrt/Version.map @@ -26,6 +26,7 @@ CXXABI_1.3 { __cxa_pure_virtual; __cxa_rethrow; __cxa_throw; + __cxa_throw_bad_array_new_length; __cxa_type_match; __cxa_vec_cctor; __cxa_vec_cleanup; @@ -273,6 +274,9 @@ CXXRT_1.0 { "std::bad_alloc::bad_alloc(std::bad_alloc const&)"; "std::bad_alloc::bad_alloc()"; "std::bad_alloc::operator=(std::bad_alloc const&)"; + "std::bad_array_new_length::bad_array_new_length(std::bad_array_new_length const&)"; + "std::bad_array_new_length::bad_array_new_length()"; + "std::bad_array_new_length::operator=(std::bad_array_new_length const&)"; }; __cxa_allocate_dependent_exception; @@ -307,6 +311,7 @@ GLIBCXX_3.4 { "std::bad_typeid::~bad_typeid()"; "std::exception::~exception()"; "std::bad_alloc::~bad_alloc()"; + "std::bad_array_new_length::~bad_array_new_length()"; "std::exception::what() const"; @@ -320,17 +325,20 @@ GLIBCXX_3.4 { "vtable for std::bad_typeid"; "vtable for std::exception"; "vtable for std::type_info"; + "vtable for std::bad_array_new_length"; "typeinfo for std::bad_alloc"; "typeinfo for std::bad_typeid"; "typeinfo for std::bad_cast"; "typeinfo for std::exception"; "typeinfo for std::type_info"; + "typeinfo for std::bad_array_new_length"; "typeinfo name for std::bad_alloc"; "typeinfo name for std::bad_typeid"; "typeinfo name for std::bad_cast"; "typeinfo name for std::exception"; "typeinfo name for std::type_info"; + "typeinfo name for std::bad_array_new_length"; }; }; @@ -340,6 +348,7 @@ GLIBCXX_3.4.9 { "std::bad_typeid::what() const"; "std::bad_cast::what() const"; "std::bad_alloc::what() const"; + "std::bad_array_new_length::what() const"; }; } GLIBCXX_3.4; -- 2.45.0