From b586b32f0a9dc8429178624aa91dbe30e0ab91e7 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 5 Mar 2014 19:30:36 +0000 Subject: [PATCH] MFC r261283: Import libc++ 3.4 release. This contains a lot of bugfixes, and some preliminary support for C++1y. MFC r261604: HEAD is not buildable for the past day. Commit a 'quick fix' in order to permit buildworld to complete. Reviewed by: theraven MFC r261608: Apply a cleaner solution for the sign warnings that can occur when compiling libc++'s header with -Wsystem-headers on. This has also been submitted upstream. Reported by: asomers MFC r261801: An ABI incompatibility crept into the libc++ 3.4 import in r261283. It was caused by upstream libc++ commit r194536, which aimed to make the headers more standards-compliant, by making std::pair's copy constructor trivial. Unfortunately, this could cause certain C++ applications using shared libraries built against the previous version of libc++ to crash. Fix the ABI incompatibility by making std::pair's copy constructor non-trivial again. Please note: Any C++ applications or shared libraries built with libc++ between r261283 and this revision should be recompiled. Reported by: stefanf git-svn-id: svn://svn.freebsd.org/base/stable/9@262801 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/libc++/CREDITS.TXT | 36 +- contrib/libc++/include/__bit_reference | 26 +- contrib/libc++/include/__config | 145 +++- contrib/libc++/include/__debug | 27 +- contrib/libc++/include/__functional_03 | 62 +- contrib/libc++/include/__functional_base | 188 ++++- contrib/libc++/include/__functional_base_03 | 2 +- contrib/libc++/include/__hash_table | 620 ++++++++++++++-- contrib/libc++/include/__locale | 48 +- contrib/libc++/include/__mutex_base | 35 +- contrib/libc++/include/__split_buffer | 18 +- contrib/libc++/include/__std_stream | 14 + contrib/libc++/include/__tree | 61 +- contrib/libc++/include/__tuple | 48 +- contrib/libc++/include/__tuple_03 | 4 +- contrib/libc++/include/__undef_min_max | 10 + contrib/libc++/include/algorithm | 258 ++++--- contrib/libc++/include/array | 59 +- contrib/libc++/include/bitset | 8 +- contrib/libc++/include/cctype | 4 +- contrib/libc++/include/chrono | 215 ++++-- contrib/libc++/include/cmath | 81 +- contrib/libc++/include/codecvt | 39 +- contrib/libc++/include/complex | 153 ++-- contrib/libc++/include/cstddef | 2 +- contrib/libc++/include/cstdio | 13 +- contrib/libc++/include/cstdlib | 10 +- contrib/libc++/include/cstring | 4 +- contrib/libc++/include/cwchar | 12 +- contrib/libc++/include/deque | 44 +- contrib/libc++/include/exception | 8 +- contrib/libc++/include/experimental/dynarray | 314 ++++++++ contrib/libc++/include/experimental/optional | 699 ++++++++++++++++++ contrib/libc++/include/ext/__hash | 6 +- contrib/libc++/include/ext/hash_map | 34 +- contrib/libc++/include/ext/hash_set | 10 +- contrib/libc++/include/forward_list | 40 +- contrib/libc++/include/fstream | 8 +- contrib/libc++/include/functional | 620 ++++++++++++---- contrib/libc++/include/future | 122 ++- contrib/libc++/include/initializer_list | 35 +- contrib/libc++/include/iomanip | 149 ++++ contrib/libc++/include/ios | 67 +- contrib/libc++/include/iosfwd | 38 +- contrib/libc++/include/istream | 21 +- contrib/libc++/include/iterator | 529 +++---------- contrib/libc++/include/limits | 16 +- contrib/libc++/include/list | 52 +- contrib/libc++/include/locale | 555 ++++---------- contrib/libc++/include/map | 380 +++++++--- contrib/libc++/include/memory | 179 ++--- contrib/libc++/include/mutex | 4 +- contrib/libc++/include/new | 61 +- contrib/libc++/include/numeric | 4 +- contrib/libc++/include/ostream | 25 +- contrib/libc++/include/queue | 10 +- contrib/libc++/include/random | 131 ++-- contrib/libc++/include/ratio | 22 +- contrib/libc++/include/regex | 85 ++- contrib/libc++/include/scoped_allocator | 2 +- contrib/libc++/include/set | 168 ++++- contrib/libc++/include/shared_mutex | 419 +++++++++++ contrib/libc++/include/sstream | 8 +- contrib/libc++/include/stack | 6 +- contrib/libc++/include/streambuf | 10 +- contrib/libc++/include/string | 735 +++++++++++-------- contrib/libc++/include/system_error | 22 +- contrib/libc++/include/thread | 15 +- contrib/libc++/include/tuple | 292 ++++---- contrib/libc++/include/type_traits | 480 ++++++------ contrib/libc++/include/typeindex | 6 +- contrib/libc++/include/unordered_map | 427 ++++++++--- contrib/libc++/include/unordered_set | 243 +++++- contrib/libc++/include/utility | 178 +++-- contrib/libc++/include/valarray | 46 +- contrib/libc++/include/vector | 217 +++--- contrib/libc++/src/algorithm.cpp | 1 + contrib/libc++/src/debug.cpp | 110 +-- contrib/libc++/src/exception.cpp | 121 ++- contrib/libc++/src/future.cpp | 6 + contrib/libc++/src/ios.cpp | 9 +- contrib/libc++/src/iostream.cpp | 16 +- contrib/libc++/src/locale.cpp | 127 +++- contrib/libc++/src/mutex.cpp | 3 + contrib/libc++/src/new.cpp | 56 +- contrib/libc++/src/optional.cpp | 25 + contrib/libc++/src/random.cpp | 28 + contrib/libc++/src/shared_mutex.cpp | 101 +++ contrib/libc++/src/stdexcept.cpp | 18 +- contrib/libc++/src/string.cpp | 12 +- contrib/libc++/src/strstream.cpp | 14 +- contrib/libc++/src/system_error.cpp | 1 + contrib/libc++/src/thread.cpp | 10 +- contrib/libc++/src/typeinfo.cpp | 15 +- contrib/libc++/src/valarray.cpp | 2 + etc/mtree/BSD.include.dist | 2 + lib/libc++/Makefile | 13 +- sys/sys/param.h | 2 +- tools/build/mk/OptionalObsoleteFiles.inc | 3 + 99 files changed, 7212 insertions(+), 3227 deletions(-) create mode 100644 contrib/libc++/include/experimental/dynarray create mode 100644 contrib/libc++/include/experimental/optional create mode 100644 contrib/libc++/include/shared_mutex create mode 100644 contrib/libc++/src/optional.cpp create mode 100644 contrib/libc++/src/shared_mutex.cpp diff --git a/contrib/libc++/CREDITS.TXT b/contrib/libc++/CREDITS.TXT index c34e21911..368b526fc 100644 --- a/contrib/libc++/CREDITS.TXT +++ b/contrib/libc++/CREDITS.TXT @@ -31,6 +31,14 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. N: Marshall Clow E: mclow.lists@gmail.com E: marshall@idio.com +D: C++14 support, patches and bug fixes. + +N: Bill Fisher +E: william.w.fisher@gmail.com +D: Regex bug fixes. + +N: Matthew Dempsky +E: matthew@dempsky.org D: Minor patches and bug fixes. N: Google Inc. @@ -48,6 +56,10 @@ N: Argyrios Kyrtzidis E: kyrtzidis@apple.com D: Bug fixes. +N: Bruce Mitchener, Jr. +E: bruce.mitchener@gmail.com +D: Emscripten-related changes. + N: Michel Morin E: mimomorin@gmail.com D: Minor patches to is_convertible. @@ -64,6 +76,10 @@ N: Bjorn Reese E: breese@users.sourceforge.net D: Initial regex prototype +N: Nico Rieck +E: nico.rieck@gmail.com +D: Windows fixes + N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -74,6 +90,14 @@ D: Implemented Cityhash as the string hash function on 64-bit machines N: Richard Smith D: Minor patches. +N: Joerg Sonnenberger +E: joerg@NetBSD.org +D: NetBSD port. + +N: Stephan Tolksdorf +E: st@quanttec.com +D: Minor fix + N: Michael van der Westhuizen E: r1mikey at gmail dot com @@ -85,11 +109,15 @@ N: Zhang Xiongpang E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. +N: Xing Xue +E: xingxue@ca.ibm.com +D: AIX port + +N: Zhihao Yuan +E: lichray@gmail.com +D: Standard compatibility fixes. + N: Jeffrey Yasskin E: jyasskin@gmail.com E: jyasskin@google.com D: Linux fixes. - -N: Bruce Mitchener, Jr. -E: bruce.mitchener@gmail.com -D: Emscripten-related changes. diff --git a/contrib/libc++/include/__bit_reference b/contrib/libc++/include/__bit_reference index 8ff3bf6d9..37b792371 100644 --- a/contrib/libc++/include/__bit_reference +++ b/contrib/libc++/include/__bit_reference @@ -40,7 +40,7 @@ class __bit_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -82,7 +82,7 @@ class __bit_reference<_Cp, false> }; template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -92,7 +92,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT { @@ -102,7 +102,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT { @@ -112,7 +112,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -130,7 +130,7 @@ class __bit_const_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -173,6 +173,8 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __storage_type __b = *__first.__seg_ & __m; if (__b) return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + if (__n == __dn) + return _It(__first.__seg_, __first.__ctz_ + __n); __n -= __dn; ++__first.__seg_; } @@ -207,6 +209,8 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __storage_type __b = ~*__first.__seg_ & __m; if (__b) return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + if (__n == __dn) + return _It(__first.__seg_, __first.__ctz_ + __n); __n -= __dn; ++__first.__seg_; } @@ -375,7 +379,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) { @@ -1104,7 +1108,11 @@ private: unsigned __ctz_; public: - _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __seg_(nullptr), __ctz_(0) +#endif + {} _LIBCPP_INLINE_VISIBILITY __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT @@ -1214,7 +1222,7 @@ private: __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT : __seg_(__s), __ctz_(__ctz) {} -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; diff --git a/contrib/libc++/include/__config b/contrib/libc++/include/__config index ca850d39b..a8c3498b0 100644 --- a/contrib/libc++/include/__config +++ b/contrib/libc++/include/__config @@ -11,7 +11,7 @@ #ifndef _LIBCPP_CONFIG #define _LIBCPP_CONFIG -#ifndef _MSC_VER // explicit macro necessary because it is only defined below in this file +#if !defined(_MSC_VER) || defined(__clang__) #pragma GCC system_header #endif @@ -72,15 +72,26 @@ # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 // Compiler intrinsics (GCC or MSVC) -# if (defined(_MSC_VER) && _MSC_VER >= 1400) \ +# if defined(__clang__) \ + || (defined(_MSC_VER) && _MSC_VER >= 1400) \ || (defined(__GNUC__) && _GNUC_VER > 403) -# define _LIBCP_HAS_IS_BASE_OF +# define _LIBCPP_HAS_IS_BASE_OF +# endif +# if defined(_MSC_VER) && !defined(__clang__) +# define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler +# define _LIBCPP_TOSTRING2(x) #x +# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) +# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) +# endif +# // If mingw not explicitly detected, assume using MS C runtime only. +# ifndef __MINGW32__ +# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif #endif // _WIN32 #ifdef __linux__ # if defined(__GNUC__) && _GNUC_VER >= 403 -# define _LIBCP_HAS_IS_BASE_OF +# define _LIBCPP_HAS_IS_BASE_OF # endif #endif @@ -127,8 +138,11 @@ # define _LIBCPP_TYPE_VIS #endif +#define _LIBCPP_TYPE_VIS_ONLY +#define _LIBCPP_FUNC_VIS_ONLY + #ifndef _LIBCPP_INLINE_VISIBILITY -# ifdef _MSC_VER +# ifdef _LIBCPP_MSVC # define _LIBCPP_INLINE_VISIBILITY __forceinline # else // MinGW GCC and Clang # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) @@ -140,7 +154,7 @@ #endif #ifndef _LIBCPP_ALWAYS_INLINE -# ifdef _MSC_VER +# ifdef _LIBCPP_MSVC # define _LIBCPP_ALWAYS_INLINE __forceinline # endif #endif @@ -160,13 +174,21 @@ #endif #ifndef _LIBCPP_TYPE_VIS -# if __has_attribute(type_visibility) +# if __has_attribute(__type_visibility__) # define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) # endif #endif +#ifndef _LIBCPP_TYPE_VIS_ONLY +# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS +#endif + +#ifndef _LIBCPP_FUNC_VIS_ONLY +# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS +#endif + #ifndef _LIBCPP_INLINE_VISIBILITY #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif @@ -175,10 +197,6 @@ #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS #endif -#ifndef _LIBCPP_CANTTHROW -#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) -#endif - #ifndef _LIBCPP_ALWAYS_INLINE #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif @@ -273,7 +291,7 @@ typedef __char32_t char32_t; #endif #if __has_feature(is_base_of) -# define _LIBCP_HAS_IS_BASE_OF +# define _LIBCPP_HAS_IS_BASE_OF #endif // Objective-C++ features (opt-in) @@ -396,13 +414,14 @@ namespace _LIBCPP_NAMESPACE { using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); } -#elif defined(_MSC_VER) +#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_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) @@ -415,10 +434,43 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std +# define _LIBCPP_WEAK namespace std { } -#endif // __clang__ || __GNUC___ || _MSC_VER +#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 _NOEXCEPT throw() +#define _NOEXCEPT_(x) + +#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +#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) +#define __MULTILOCALE_API +#endif + +#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { +#define _LIBCPP_END_NAMESPACE_STD } } +#define _VSTD std::_LIBCPP_NAMESPACE + +namespace std { + inline namespace _LIBCPP_NAMESPACE { + } +} + +#endif // __clang__ || __GNUC___ || _MSC_VER || __IBMCPP__ #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; @@ -481,8 +533,23 @@ template struct __static_assert_check {}; #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS +#ifdef _LIBCPP_DEBUG +# if _LIBCPP_DEBUG == 0 +# define _LIBCPP_DEBUG_LEVEL 1 +# elif _LIBCPP_DEBUG == 1 +# define _LIBCPP_DEBUG_LEVEL 2 +# else +# error Supported values for _LIBCPP_DEBUG are 0 and 1 +# endif +# define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + #ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +#define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + +#ifndef _LIBCPP_EXTERN_TEMPLATE2 +#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__) @@ -500,14 +567,14 @@ template struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#ifdef _LIBCPP_DEBUG2 -# if _LIBCPP_DEBUG2 == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG2 == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG2 are 0 and 1 -# endif +#if defined(__APPLE__) || defined(__FreeBSD__) +#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0 +#endif +#endif + +#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 #endif #ifndef _LIBCPP_STD_VER @@ -518,10 +585,36 @@ template struct __static_assert_check {}; # endif #endif // _LIBCPP_STD_VER -#ifdef _LIBCPP_DEBUG2 -# include <__debug> +#if _LIBCPP_STD_VER > 11 +#define _LIBCPP_DEPRECATED [[deprecated]] +#else +#define _LIBCPP_DEPRECATED +#endif + +#if _LIBCPP_STD_VER <= 11 +#define _LIBCPP_CONSTEXPR_AFTER_CXX11 +#define _LIBCPP_EXPLICIT_AFTER_CXX11 +#define _LIBCPP_DEPRECATED_AFTER_CXX11 #else -# define _LIBCPP_ASSERT(x, m) ((void)0) +#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit +#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] +#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) +# define _LIBCPP_NO_RTTI +# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) +# define _LIBCPP_NO_RTTI +# endif +#endif + +#ifndef _LIBCPP_WEAK +# define _LIBCPP_WEAK __attribute__((__weak__)) #endif #endif // _LIBCPP_CONFIG diff --git a/contrib/libc++/include/__debug b/contrib/libc++/include/__debug index 0d631bf04..f1805adcf 100644 --- a/contrib/libc++/include/__debug +++ b/contrib/libc++/include/__debug @@ -11,6 +11,10 @@ #ifndef _LIBCPP_DEBUG_H #define _LIBCPP_DEBUG_H +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #if _LIBCPP_DEBUG_LEVEL >= 1 # include @@ -34,8 +38,15 @@ struct _LIBCPP_TYPE_VIS __i_node __i_node* __next_; __c_node* __c_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __i_node(const __i_node&) = delete; __i_node& operator=(const __i_node&) = delete; +#else +private: + __i_node(const __i_node&); + __i_node& operator=(const __i_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __i_node(void* __i, __i_node* __next, __c_node* __c) : __i_(__i), __next_(__next), __c_(__c) {} @@ -50,8 +61,15 @@ struct _LIBCPP_TYPE_VIS __c_node __i_node** end_; __i_node** cap_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __c_node(const __c_node&) = delete; __c_node& operator=(const __c_node&) = delete; +#else +private: + __c_node(const __c_node&); + __c_node& operator=(const __c_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __c_node(void* __c, __c_node* __next) : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} @@ -130,8 +148,15 @@ class _LIBCPP_TYPE_VIS __libcpp_db __libcpp_db(); public: +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __libcpp_db(const __libcpp_db&) = delete; __libcpp_db& operator=(const __libcpp_db&) = delete; +#else +private: + __libcpp_db(const __libcpp_db&); + __libcpp_db& operator=(const __libcpp_db&); +public: +#endif ~__libcpp_db(); class __db_c_iterator; @@ -171,7 +196,7 @@ public: bool __decrementable(const void* __i) const; bool __addable(const void* __i, ptrdiff_t __n) const; bool __subscriptable(const void* __i, ptrdiff_t __n) const; - bool __comparable(const void* __i, const void* __j) const; + bool __less_than_comparable(const void* __i, const void* __j) const; private: _LIBCPP_HIDDEN __i_node* __insert_iterator(void* __i); diff --git a/contrib/libc++/include/__functional_03 b/contrib/libc++/include/__functional_03 index b52d69268..f9a3d9766 100644 --- a/contrib/libc++/include/__functional_03 +++ b/contrib/libc++/include/__functional_03 @@ -102,98 +102,98 @@ mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2)) template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)()> +__mem_fn<_Rp (_Tp::*)() const> mem_fn(_Rp (_Tp::* __pm)() const) { - return __mem_fn<_Rp (_Tp::*)()>(__pm); + return __mem_fn<_Rp (_Tp::*)() const>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0)> +__mem_fn<_Rp (_Tp::*)(_A0) const> mem_fn(_Rp (_Tp::* __pm)(_A0) const) { - return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0) const>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1) const> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)()> +__mem_fn<_Rp (_Tp::*)() volatile> mem_fn(_Rp (_Tp::* __pm)() volatile) { - return __mem_fn<_Rp (_Tp::*)()>(__pm); + return __mem_fn<_Rp (_Tp::*)() volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0)> +__mem_fn<_Rp (_Tp::*)(_A0) volatile> mem_fn(_Rp (_Tp::* __pm)(_A0) volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0) volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)()> +__mem_fn<_Rp (_Tp::*)() const volatile> mem_fn(_Rp (_Tp::* __pm)() const volatile) { - return __mem_fn<_Rp (_Tp::*)()>(__pm); + return __mem_fn<_Rp (_Tp::*)() const volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0)> +__mem_fn<_Rp (_Tp::*)(_A0) const volatile> mem_fn(_Rp (_Tp::* __pm)(_A0) const volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0) const volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>(__pm); } template inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)> +__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile> mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const volatile) { - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm); + return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>(__pm); } // bad_function_call @@ -203,7 +203,7 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call { }; -template class _LIBCPP_TYPE_VIS function; // undefined +template class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { @@ -644,7 +644,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const } // __function template -class _LIBCPP_TYPE_VIS function<_Rp()> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> { typedef __function::__base<_Rp()> __base; aligned_storage<3*sizeof(void*)>::type __buf_; @@ -928,7 +928,7 @@ function<_Rp()>::target() const #endif // _LIBCPP_NO_RTTI template -class _LIBCPP_TYPE_VIS function<_Rp(_A0)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> : public unary_function<_A0, _Rp> { typedef __function::__base<_Rp(_A0)> __base; @@ -1230,7 +1230,7 @@ function<_Rp(_A0)>::target() const #endif // _LIBCPP_NO_RTTI template -class _LIBCPP_TYPE_VIS function<_Rp(_A0, _A1)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> : public binary_function<_A0, _A1, _Rp> { typedef __function::__base<_Rp(_A0, _A1)> __base; @@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1)>::target() const #endif // _LIBCPP_NO_RTTI template -class _LIBCPP_TYPE_VIS function<_Rp(_A0, _A1, _A2)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> { typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; aligned_storage<3*sizeof(void*)>::type __buf_; @@ -1860,11 +1860,11 @@ swap(function<_Fp>& __x, function<_Fp>& __y) {return __x.swap(__y);} template struct __is_bind_expression : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_bind_expression +template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression::type> {}; template struct __is_placeholder : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS is_placeholder +template struct _LIBCPP_TYPE_VIS_ONLY is_placeholder : public __is_placeholder::type> {}; namespace placeholders diff --git a/contrib/libc++/include/__functional_base b/contrib/libc++/include/__functional_base index 5b0d7201d..1c337d8b4 100644 --- a/contrib/libc++/include/__functional_base +++ b/contrib/libc++/include/__functional_base @@ -15,6 +15,7 @@ #include #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -23,21 +24,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD template -struct _LIBCPP_TYPE_VIS unary_function +struct _LIBCPP_TYPE_VIS_ONLY unary_function { typedef _Arg argument_type; typedef _Result result_type; }; template -struct _LIBCPP_TYPE_VIS binary_function +struct _LIBCPP_TYPE_VIS_ONLY binary_function { typedef _Arg1 first_argument_type; typedef _Arg2 second_argument_type; typedef _Result result_type; }; -template struct _LIBCPP_TYPE_VIS hash; +template struct _LIBCPP_TYPE_VIS_ONLY hash; template struct __has_result_type @@ -50,13 +51,80 @@ public: static const bool value = sizeof(__test<_Tp>(0)) == 1; }; +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS less : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY less +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +// addressof + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return (_Tp*)&reinterpret_cast(__x); +} + +#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) +// Objective-C++ Automatic Reference Counting uses qualified pointers +// that require special addressof() signatures. When +// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler +// itself is providing these definitions. Otherwise, we provide them. +template +inline _LIBCPP_INLINE_VISIBILITY +__strong _Tp* +addressof(__strong _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +template +inline _LIBCPP_INLINE_VISIBILITY +__weak _Tp* +addressof(__weak _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +__autoreleasing _Tp* +addressof(__autoreleasing _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__unsafe_unretained _Tp* +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + #ifdef _LIBCPP_HAS_NO_VARIADICS #include <__functional_base_03> @@ -352,7 +420,7 @@ struct __invoke_return }; template -class _LIBCPP_TYPE_VIS reference_wrapper +class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> { public: @@ -363,7 +431,8 @@ private: public: // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {} + _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT + : __f_(_VSTD::addressof(__f)) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES private: reference_wrapper(type&&); public: // = delete; // do not bind to temps #endif @@ -436,6 +505,111 @@ template void cref(const _Tp&&);// = delete; #endif // _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 11 +template +struct __is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::is_transparent* = 0); +public: + static const bool value = sizeof(__test<_Tp1>(0)) == 1; +}; +#endif + +// allocator_arg_t + +struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { }; + +#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) +extern const allocator_arg_t allocator_arg; +#else +constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#endif + +// uses_allocator + +template +struct __has_allocator_type +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::allocator_type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +template ::value> +struct __uses_allocator + : public integral_constant::value> +{ +}; + +template +struct __uses_allocator<_Tp, _Alloc, false> + : public false_type +{ +}; + +template +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator + : public __uses_allocator<_Tp, _Alloc> +{ +}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +// allocator construction + +template +struct __uses_alloc_ctor_imp +{ + static const bool __ua = uses_allocator<_Tp, _Alloc>::value; + static const bool __ic = + is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + static const int value = __ua ? 2 - __ic : 0; +}; + +template +struct __uses_alloc_ctor + : integral_constant::value> + {}; + +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args) +{ + __user_alloc_construct_impl( + __uses_alloc_ctor<_Tp, _Allocator>(), + __storage, __a, _VSTD::forward<_Args>(__args)... + ); +} +#endif // _LIBCPP_HAS_NO_VARIADICS + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FUNCTIONAL_BASE diff --git a/contrib/libc++/include/__functional_base_03 b/contrib/libc++/include/__functional_base_03 index 11165a964..296dd8db3 100644 --- a/contrib/libc++/include/__functional_base_03 +++ b/contrib/libc++/include/__functional_base_03 @@ -996,7 +996,7 @@ struct __invoke_return2 }; template -class _LIBCPP_TYPE_VIS reference_wrapper +class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> { public: diff --git a/contrib/libc++/include/__hash_table b/contrib/libc++/include/__hash_table index 2b282d33a..4c4feb03e 100644 --- a/contrib/libc++/include/__hash_table +++ b/contrib/libc++/include/__hash_table @@ -20,6 +20,12 @@ #include <__undef_min_max> +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -79,14 +85,14 @@ __next_pow2(size_t __n) } template class __hash_table; -template class _LIBCPP_TYPE_VIS __hash_const_iterator; -template class _LIBCPP_TYPE_VIS __hash_map_iterator; -template class _LIBCPP_TYPE_VIS __hash_map_const_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; template - class _LIBCPP_TYPE_VIS unordered_map; + class _LIBCPP_TYPE_VIS_ONLY unordered_map; template -class _LIBCPP_TYPE_VIS __hash_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_iterator { typedef _NodePtr __node_pointer; @@ -105,16 +111,70 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __node_(nullptr) +#endif + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_i(this); +#endif + } + +#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __node_->__value_;} + __hash_iterator(const __hash_iterator& __i) + : __node_(__i.__node_) + { + __get_db()->__iterator_copy(this, &__i); + } + _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} + ~__hash_iterator() + { + __get_db()->__erase_i(this); + } + + _LIBCPP_INLINE_VISIBILITY + __hash_iterator& operator=(const __hash_iterator& __i) + { + if (this != &__i) + { + __get_db()->__iterator_copy(this, &__i); + __node_ = __i.__node_; + } + return *this; + } + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container iterator"); +#endif + return __node_->__value_; + } + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container iterator"); +#endif + return pointer_traits::pointer_to(__node_->__value_); + } _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator++() { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment non-incrementable unordered container iterator"); +#endif __node_ = __node_->__next_; return *this; } @@ -129,26 +189,37 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_iterator& __x, const __hash_iterator& __y) - {return __x.__node_ == __y.__node_;} + { + return __x.__node_ == __y.__node_; + } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y) - {return __x.__node_ != __y.__node_;} + {return !(__x == __y);} private: +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + __hash_iterator(__node_pointer __node, const void* __c) _NOEXCEPT + : __node_(__node) + { + __get_db()->__insert_ic(this, __c); + } +#else _LIBCPP_INLINE_VISIBILITY __hash_iterator(__node_pointer __node) _NOEXCEPT : __node_(__node) {} +#endif template friend class __hash_table; - template friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_map_iterator; - template friend class _LIBCPP_TYPE_VIS unordered_map; - template friend class _LIBCPP_TYPE_VIS unordered_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template -class _LIBCPP_TYPE_VIS __hash_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator { typedef _ConstNodePtr __node_pointer; @@ -179,20 +250,78 @@ public: __non_const_node_pointer; typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator; - _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __node_(nullptr) +#endif + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_i(this); +#endif + } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) - {} + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__iterator_copy(this, &__x); +#endif + } + +#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __node_->__value_;} + __hash_const_iterator(const __hash_const_iterator& __i) + : __node_(__i.__node_) + { + __get_db()->__iterator_copy(this, &__i); + } + + _LIBCPP_INLINE_VISIBILITY + ~__hash_const_iterator() + { + __get_db()->__erase_i(this); + } + _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} + __hash_const_iterator& operator=(const __hash_const_iterator& __i) + { + if (this != &__i) + { + __get_db()->__iterator_copy(this, &__i); + __node_ = __i.__node_; + } + return *this; + } + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container const_iterator"); +#endif + return __node_->__value_; + } + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container const_iterator"); +#endif + return pointer_traits::pointer_to(__node_->__value_); + } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator++() { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment non-incrementable unordered container const_iterator"); +#endif __node_ = __node_->__next_; return *this; } @@ -207,27 +336,38 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - {return __x.__node_ == __y.__node_;} + { + return __x.__node_ == __y.__node_; + } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - {return __x.__node_ != __y.__node_;} + {return !(__x == __y);} private: +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + __hash_const_iterator(__node_pointer __node, const void* __c) _NOEXCEPT + : __node_(__node) + { + __get_db()->__insert_ic(this, __c); + } +#else _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(__node_pointer __node) _NOEXCEPT : __node_(__node) {} +#endif template friend class __hash_table; - template friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; - template friend class _LIBCPP_TYPE_VIS unordered_map; - template friend class _LIBCPP_TYPE_VIS unordered_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; -template class _LIBCPP_TYPE_VIS __hash_const_local_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template -class _LIBCPP_TYPE_VIS __hash_local_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator { typedef _NodePtr __node_pointer; @@ -249,16 +389,71 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_i(this); +#endif + } + +#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __node_->__value_;} + __hash_local_iterator(const __hash_local_iterator& __i) + : __node_(__i.__node_), + __bucket_(__i.__bucket_), + __bucket_count_(__i.__bucket_count_) + { + __get_db()->__iterator_copy(this, &__i); + } + + _LIBCPP_INLINE_VISIBILITY + ~__hash_local_iterator() + { + __get_db()->__erase_i(this); + } + _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} + __hash_local_iterator& operator=(const __hash_local_iterator& __i) + { + if (this != &__i) + { + __get_db()->__iterator_copy(this, &__i); + __node_ = __i.__node_; + __bucket_ = __i.__bucket_; + __bucket_count_ = __i.__bucket_count_; + } + return *this; + } + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container local_iterator"); +#endif + return __node_->__value_; + } + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container local_iterator"); +#endif + return pointer_traits::pointer_to(__node_->__value_); + } _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator++() { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment non-incrementable unordered container local_iterator"); +#endif __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_) __node_ = nullptr; @@ -275,12 +470,27 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - {return __x.__node_ == __y.__node_;} + { + return __x.__node_ == __y.__node_; + } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - {return __x.__node_ != __y.__node_;} + {return !(__x == __y);} private: +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + __hash_local_iterator(__node_pointer __node, size_t __bucket, + size_t __bucket_count, const void* __c) _NOEXCEPT + : __node_(__node), + __bucket_(__bucket), + __bucket_count_(__bucket_count) + { + __get_db()->__insert_ic(this, __c); + if (__node_ != nullptr) + __node_ = __node_->__next_; + } +#else _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count) _NOEXCEPT @@ -291,14 +501,14 @@ private: if (__node_ != nullptr) __node_ = __node_->__next_; } - +#endif template friend class __hash_table; - template friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_map_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; }; template -class _LIBCPP_TYPE_VIS __hash_const_local_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator { typedef _ConstNodePtr __node_pointer; @@ -333,22 +543,82 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_i(this); +#endif + } + _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_), __bucket_(__x.__bucket_), __bucket_count_(__x.__bucket_count_) - {} + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__iterator_copy(this, &__x); +#endif + } + +#if _LIBCPP_DEBUG_LEVEL >= 2 + + _LIBCPP_INLINE_VISIBILITY + __hash_const_local_iterator(const __hash_const_local_iterator& __i) + : __node_(__i.__node_), + __bucket_(__i.__bucket_), + __bucket_count_(__i.__bucket_count_) + { + __get_db()->__iterator_copy(this, &__i); + } _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __node_->__value_;} + ~__hash_const_local_iterator() + { + __get_db()->__erase_i(this); + } + _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} + __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) + { + if (this != &__i) + { + __get_db()->__iterator_copy(this, &__i); + __node_ = __i.__node_; + __bucket_ = __i.__bucket_; + __bucket_count_ = __i.__bucket_count_; + } + return *this; + } + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); +#endif + return __node_->__value_; + } + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); +#endif + return pointer_traits::pointer_to(__node_->__value_); + } _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator++() { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment non-incrementable unordered container const_local_iterator"); +#endif __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_) __node_ = nullptr; @@ -365,12 +635,27 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - {return __x.__node_ == __y.__node_;} + { + return __x.__node_ == __y.__node_; + } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - {return __x.__node_ != __y.__node_;} + {return !(__x == __y);} private: +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + __hash_const_local_iterator(__node_pointer __node, size_t __bucket, + size_t __bucket_count, const void* __c) _NOEXCEPT + : __node_(__node), + __bucket_(__bucket), + __bucket_count_(__bucket_count) + { + __get_db()->__insert_ic(this, __c); + if (__node_ != nullptr) + __node_ = __node_->__next_; + } +#else _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count) _NOEXCEPT @@ -381,9 +666,9 @@ private: if (__node_ != nullptr) __node_ = __node_->__next_; } - +#endif template friend class __hash_table; - template friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template @@ -664,7 +949,11 @@ public: template _LIBCPP_INLINE_VISIBILITY size_type bucket(const _Key& __k) const - {return __constrain_hash(hash_function()(__k), bucket_count());} + { + _LIBCPP_ASSERT(bucket_count() > 0, + "unordered container::bucket(key) called when bucket_count() == 0"); + return __constrain_hash(hash_function()(__k), bucket_count()); + } template iterator find(const _Key& __x); @@ -720,16 +1009,73 @@ public: return __bc != 0 ? (float)size() / __bc : 0.f; } _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT - {max_load_factor() = _VSTD::max(__mlf, load_factor());} - - _LIBCPP_INLINE_VISIBILITY local_iterator begin(size_type __n) - {return local_iterator(__bucket_list_[__n], __n, bucket_count());} - _LIBCPP_INLINE_VISIBILITY local_iterator end(size_type __n) - {return local_iterator(nullptr, __n, bucket_count());} - _LIBCPP_INLINE_VISIBILITY const_local_iterator cbegin(size_type __n) const - {return const_local_iterator(__bucket_list_[__n], __n, bucket_count());} - _LIBCPP_INLINE_VISIBILITY const_local_iterator cend(size_type __n) const - {return const_local_iterator(nullptr, __n, bucket_count());} + { + _LIBCPP_ASSERT(__mlf > 0, + "unordered container::max_load_factor(lf) called with lf <= 0"); + max_load_factor() = _VSTD::max(__mlf, load_factor()); + } + + _LIBCPP_INLINE_VISIBILITY + local_iterator + begin(size_type __n) + { + _LIBCPP_ASSERT(__n < bucket_count(), + "unordered container::begin(n) called with n >= bucket_count()"); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); +#else + return local_iterator(__bucket_list_[__n], __n, bucket_count()); +#endif + } + + _LIBCPP_INLINE_VISIBILITY + local_iterator + end(size_type __n) + { + _LIBCPP_ASSERT(__n < bucket_count(), + "unordered container::end(n) called with n >= bucket_count()"); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return local_iterator(nullptr, __n, bucket_count(), this); +#else + return local_iterator(nullptr, __n, bucket_count()); +#endif + } + + _LIBCPP_INLINE_VISIBILITY + const_local_iterator + cbegin(size_type __n) const + { + _LIBCPP_ASSERT(__n < bucket_count(), + "unordered container::cbegin(n) called with n >= bucket_count()"); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); +#else + return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); +#endif + } + + _LIBCPP_INLINE_VISIBILITY + const_local_iterator + cend(size_type __n) const + { + _LIBCPP_ASSERT(__n < bucket_count(), + "unordered container::cend(n) called with n >= bucket_count()"); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return const_local_iterator(nullptr, __n, bucket_count(), this); +#else + return const_local_iterator(nullptr, __n, bucket_count()); +#endif + } + +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const; + bool __decrementable(const const_iterator* __i) const; + bool __addable(const const_iterator* __i, ptrdiff_t __n) const; + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: void __rehash(size_type __n); @@ -814,8 +1160,8 @@ private: void __deallocate(__node_pointer __np) _NOEXCEPT; __node_pointer __detach() _NOEXCEPT; - template friend class _LIBCPP_TYPE_VIS unordered_map; - template friend class _LIBCPP_TYPE_VIS unordered_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template @@ -939,6 +1285,9 @@ template __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { __deallocate(__p1_.first().__next_); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__erase_c(this); +#endif } template @@ -980,6 +1329,21 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np) while (__np != nullptr) { __node_pointer __next = __np->__next_; +#if _LIBCPP_DEBUG_LEVEL >= 2 + __c_node* __c = __get_db()->__find_c_and_lock(this); + for (__i_node** __p = __c->end_; __p != __c->beg_; ) + { + --__p; + iterator* __i = static_cast((*__p)->__i_); + if (__i->__node_ == __np) + { + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + } + } + __get_db()->unlock(); +#endif __node_traits::destroy(__na, _VSTD::addressof(__np->__value_)); __node_traits::deallocate(__na, __np, 1); __np = __next; @@ -1027,6 +1391,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->swap(this, &__u); +#endif } template @@ -1167,7 +1534,11 @@ inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(__p1_.first().__next_, this); +#else return iterator(__p1_.first().__next_); +#endif } template @@ -1175,7 +1546,11 @@ inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(nullptr, this); +#else return iterator(nullptr); +#endif } template @@ -1183,7 +1558,11 @@ inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { +#if _LIBCPP_DEBUG_LEVEL >= 2 + return const_iterator(__p1_.first().__next_, this); +#else return const_iterator(__p1_.first().__next_); +#endif } template @@ -1191,7 +1570,11 @@ inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { +#if _LIBCPP_DEBUG_LEVEL >= 2 + return const_iterator(nullptr, this); +#else return const_iterator(nullptr); +#endif } template @@ -1264,7 +1647,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ __inserted = true; } __done: +#if _LIBCPP_DEBUG_LEVEL >= 2 + return pair(iterator(__ndptr, this), __inserted); +#else return pair(iterator(__ndptr), __inserted); +#endif } template @@ -1321,7 +1708,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c } } ++size(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(__cp, this); +#else return iterator(__cp); +#endif } template @@ -1329,6 +1720,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( const_iterator __p, __node_pointer __cp) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered container"); +#endif if (__p != end() && key_eq()(*__p, __cp->__value_)) { __node_pointer __np = __p.__node_; @@ -1347,7 +1743,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( __cp->__next_ = __np; __pp->__next_ = __cp; ++size(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(__cp, this); +#else return iterator(__cp); +#endif } return __node_insert_multi(__cp); } @@ -1408,7 +1808,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x) __inserted = true; } __done: +#if _LIBCPP_DEBUG_LEVEL >= 2 + return pair(iterator(__nd, this), __inserted); +#else return pair(iterator(__nd), __inserted); +#endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1443,6 +1847,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( const_iterator __p, _Args&&... __args) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered container"); +#endif __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); @@ -1484,6 +1893,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, _Pp&& __x) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::insert(const_iterator, rvalue) called with an iterator not" + " referring to this unordered container"); +#endif __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x)); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); @@ -1507,6 +1921,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, const value_type& __x) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::insert(const_iterator, lvalue) called with an iterator not" + " referring to this unordered container"); +#endif __node_holder __h = __construct_node(__x); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); @@ -1543,6 +1962,9 @@ template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__invalidate_all(this); +#endif // _LIBCPP_DEBUG_LEVEL >= 2 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); __bucket_list_.reset(__nbc > 0 ? __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); @@ -1608,7 +2030,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(__nd, this); +#else return iterator(__nd); +#endif } } } @@ -1633,7 +2059,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) +#if _LIBCPP_DEBUG_LEVEL >= 2 + return const_iterator(__nd, this); +#else return const_iterator(__nd); +#endif } } @@ -1671,7 +2101,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v, __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return __h; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1686,7 +2116,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1702,7 +2132,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template @@ -1710,7 +2140,16 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { __node_pointer __np = __p.__node_; +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container erase(iterator) called with an iterator not" + " referring to this container"); + _LIBCPP_ASSERT(__p != end(), + "unordered container erase(iterator) called with a non-dereferenceable iterator"); + iterator __r(__np, this); +#else iterator __r(__np); +#endif ++__r; remove(__p); return __r; @@ -1721,13 +2160,25 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, + "unodered container::erase(iterator, iterator) called with an iterator not" + " referring to this unodered container"); + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, + "unodered container::erase(iterator, iterator) called with an iterator not" + " referring to this unodered container"); +#endif for (const_iterator __p = __first; __first != __last; __p = __first) { ++__first; erase(__p); } __node_pointer __np = __last.__node_; +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator (__np, this); +#else return iterator (__np); +#endif } template @@ -1793,6 +2244,21 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT __pn->__next_ = __cn->__next_; __cn->__next_ = nullptr; --size(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __c_node* __c = __get_db()->__find_c_and_lock(this); + for (__i_node** __p = __c->end_; __p != __c->beg_; ) + { + --__p; + iterator* __i = static_cast((*__p)->__i_); + if (__i->__node_ == __cn) + { + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + } + } + __get_db()->unlock(); +#endif return __node_holder(__cn, _Dp(__node_alloc(), true)); } @@ -1921,12 +2387,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) if (__u.size() > 0) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first())); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->swap(this, &__u); +#endif } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const { + _LIBCPP_ASSERT(__n < bucket_count(), + "unordered container::bucket_size(n) called with n >= bucket_count()"); __node_const_pointer __np = __bucket_list_[__n]; size_type __bc = bucket_count(); size_type __r = 0; @@ -1950,6 +2421,37 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, __x.swap(__y); } +#if _LIBCPP_DEBUG_LEVEL >= 2 + +template +bool +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const +{ + return __i->__node_ != nullptr; +} + +template +bool +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const +{ + return false; +} + +template +bool +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const +{ + return false; +} + +template +bool +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const +{ + return false; +} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP__HASH_TABLE diff --git a/contrib/libc++/include/__locale b/contrib/libc++/include/__locale index 92f4e0ca7..6d75162a9 100644 --- a/contrib/libc++/include/__locale +++ b/contrib/libc++/include/__locale @@ -19,11 +19,13 @@ #include #include #include -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # include -#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(EMSCRIPTEN) +#elif _AIX +# include +#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(__EMSCRIPTEN__) || defined(__IBMCPP__) # include -#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || EMSCRIPTEN +#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -175,7 +177,7 @@ use_facet(const locale& __l) // template class collate; template -class _LIBCPP_TYPE_VIS collate +class _LIBCPP_TYPE_VIS_ONLY collate : public locale::facet { public: @@ -254,12 +256,12 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const return static_cast(__h); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate) // template class collate_byname; -template class _LIBCPP_TYPE_VIS collate_byname; +template class _LIBCPP_TYPE_VIS_ONLY collate_byname; template <> class _LIBCPP_TYPE_VIS collate_byname @@ -339,12 +341,12 @@ 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__) #ifdef __APPLE__ typedef __uint32_t mask; #elif defined(__FreeBSD__) typedef unsigned long mask; -#elif defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) typedef unsigned short mask; #endif static const mask space = _CTYPE_S; @@ -361,7 +363,7 @@ public: # else static const mask blank = _CTYPE_B; # endif -#elif defined(__sun__) +#elif defined(__sun__) || defined(_AIX) typedef unsigned int mask; static const mask space = _ISSPACE; static const mask print = _ISPRINT; @@ -373,7 +375,7 @@ public: static const mask punct = _ISPUNCT; static const mask xdigit = _ISXDIGIT; static const mask blank = _ISBLANK; -#else // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || EMSCRIPTEN || __sun__ +#else // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__ typedef unsigned long mask; static const mask space = 1<<0; static const mask print = 1<<1; @@ -392,7 +394,7 @@ public: _LIBCPP_ALWAYS_INLINE ctype_base() {} }; -template class _LIBCPP_TYPE_VIS ctype; +template class _LIBCPP_TYPE_VIS_ONLY ctype; template <> class _LIBCPP_TYPE_VIS ctype @@ -510,7 +512,7 @@ public: _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { - return isascii(__c) ? __tab_[static_cast(__c)] & __m : false; + return isascii(__c) ? (__tab_[static_cast(__c)] & __m) !=0 : false; } _LIBCPP_ALWAYS_INLINE @@ -596,7 +598,7 @@ public: #endif _LIBCPP_ALWAYS_INLINE const mask* table() const _NOEXCEPT {return __tab_;} static const mask* classic_table() _NOEXCEPT; -#if defined(__GLIBC__) || defined(EMSCRIPTEN) +#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) static const int* __classic_upper_table() _NOEXCEPT; static const int* __classic_lower_table() _NOEXCEPT; #endif @@ -619,7 +621,7 @@ protected: // template class ctype_byname; -template class _LIBCPP_TYPE_VIS ctype_byname; +template class _LIBCPP_TYPE_VIS_ONLY ctype_byname; template <> class _LIBCPP_TYPE_VIS ctype_byname @@ -780,7 +782,7 @@ public: // template class codecvt; -template class _LIBCPP_TYPE_VIS codecvt; +template class _LIBCPP_TYPE_VIS_ONLY codecvt; // template <> class codecvt @@ -1126,7 +1128,7 @@ protected: // template class codecvt_byname template -class _LIBCPP_TYPE_VIS codecvt_byname +class _LIBCPP_TYPE_VIS_ONLY codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { public: @@ -1145,10 +1147,10 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() { } -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname) _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); @@ -1334,7 +1336,7 @@ struct __widen_from_utf8<32> // template class numpunct -template class _LIBCPP_TYPE_VIS numpunct; +template class _LIBCPP_TYPE_VIS_ONLY numpunct; template <> class _LIBCPP_TYPE_VIS numpunct @@ -1400,7 +1402,7 @@ protected: // template class numpunct_byname -template class _LIBCPP_TYPE_VIS numpunct_byname; +template class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; template <> class _LIBCPP_TYPE_VIS numpunct_byname diff --git a/contrib/libc++/include/__mutex_base b/contrib/libc++/include/__mutex_base index 0583df933..d4023a64f 100644 --- a/contrib/libc++/include/__mutex_base +++ b/contrib/libc++/include/__mutex_base @@ -20,16 +20,6 @@ #pragma GCC system_header #endif -#ifdef _LIBCPP_SHARED_LOCK - -namespace ting { -template class shared_lock; -template class upgrade_lock; -} - -#endif // _LIBCPP_SHARED_LOCK - - _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS mutex @@ -77,7 +67,7 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); #endif template -class _LIBCPP_TYPE_VIS lock_guard +class _LIBCPP_TYPE_VIS_ONLY lock_guard { public: typedef _Mutex mutex_type; @@ -101,7 +91,7 @@ private: }; template -class _LIBCPP_TYPE_VIS unique_lock +class _LIBCPP_TYPE_VIS_ONLY unique_lock { public: typedef _Mutex mutex_type; @@ -162,27 +152,6 @@ public: return *this; } -#ifdef _LIBCPP_SHARED_LOCK - - unique_lock(ting::shared_lock&&, try_to_lock_t); - template - unique_lock(ting::shared_lock&&, - const chrono::time_point<_Clock, _Duration>&); - template - unique_lock(ting::shared_lock&&, - const chrono::duration<_Rep, _Period>&); - - explicit unique_lock(ting::upgrade_lock&&); - unique_lock(ting::upgrade_lock&&, try_to_lock_t); - template - unique_lock(ting::upgrade_lock&&, - const chrono::time_point<_Clock, _Duration>&); - template - unique_lock(ting::upgrade_lock&&, - const chrono::duration<_Rep, _Period>&); - -#endif // _LIBCPP_SHARED_LOCK - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void lock(); diff --git a/contrib/libc++/include/__split_buffer b/contrib/libc++/include/__split_buffer index f1c404f77..1d529cbe2 100644 --- a/contrib/libc++/include/__split_buffer +++ b/contrib/libc++/include/__split_buffer @@ -285,7 +285,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { @@ -294,7 +294,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { @@ -302,7 +302,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { @@ -311,7 +311,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT { @@ -328,7 +328,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) @@ -336,14 +336,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { @@ -541,7 +541,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) { @@ -640,7 +640,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/contrib/libc++/include/__std_stream b/contrib/libc++/include/__std_stream index cff43317e..5403adabc 100644 --- a/contrib/libc++/include/__std_stream +++ b/contrib/libc++/include/__std_stream @@ -233,6 +233,7 @@ public: protected: virtual int_type overflow (int_type __c = traits_type::eof()); + virtual streamsize xsputn(const char_type* __s, streamsize __n); virtual int sync(); virtual void imbue(const locale& __loc); @@ -308,6 +309,19 @@ __stdoutbuf<_CharT>::overflow(int_type __c) return traits_type::not_eof(__c); } +template +streamsize +__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n) +{ + if (__always_noconv_) + return fwrite(__s, sizeof(char_type), __n, __file_); + streamsize __i = 0; + for (; __i < __n; ++__i, ++__s) + if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof()) + break; + return __i; +} + template int __stdoutbuf<_CharT>::sync() diff --git a/contrib/libc++/include/__tree b/contrib/libc++/include/__tree index 9ffc38d22..acf87593a 100644 --- a/contrib/libc++/include/__tree +++ b/contrib/libc++/include/__tree @@ -25,17 +25,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD template class __tree; template - class _LIBCPP_TYPE_VIS __tree_iterator; + class _LIBCPP_TYPE_VIS_ONLY __tree_iterator; template - class _LIBCPP_TYPE_VIS __tree_const_iterator; + class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; template - class _LIBCPP_TYPE_VIS map; + class _LIBCPP_TYPE_VIS_ONLY map; template - class _LIBCPP_TYPE_VIS multimap; + class _LIBCPP_TYPE_VIS_ONLY multimap; template - class _LIBCPP_TYPE_VIS set; + class _LIBCPP_TYPE_VIS_ONLY set; template - class _LIBCPP_TYPE_VIS multiset; + class _LIBCPP_TYPE_VIS_ONLY multiset; /* @@ -614,11 +614,11 @@ public: #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) }; -template class _LIBCPP_TYPE_VIS __map_iterator; -template class _LIBCPP_TYPE_VIS __map_const_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __map_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; template -class _LIBCPP_TYPE_VIS __tree_iterator +class _LIBCPP_TYPE_VIS_ONLY __tree_iterator { typedef _NodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; @@ -641,7 +641,11 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __ptr_(nullptr) +#endif + {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -674,16 +678,16 @@ private: _LIBCPP_INLINE_VISIBILITY explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template friend class __tree; - template friend class _LIBCPP_TYPE_VIS __tree_const_iterator; - template friend class _LIBCPP_TYPE_VIS __map_iterator; - template friend class _LIBCPP_TYPE_VIS map; - template friend class _LIBCPP_TYPE_VIS multimap; - template friend class _LIBCPP_TYPE_VIS set; - template friend class _LIBCPP_TYPE_VIS multiset; + template friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __map_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY map; + template friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY set; + template friend class _LIBCPP_TYPE_VIS_ONLY multiset; }; template -class _LIBCPP_TYPE_VIS __tree_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator { typedef _ConstNodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; @@ -712,7 +716,12 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() {} + _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __ptr_(nullptr) +#endif + {} + private: typedef typename remove_const<__node>::type __non_const_node; typedef typename pointer_traits<__node_pointer>::template @@ -761,11 +770,11 @@ private: explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template friend class __tree; - template friend class _LIBCPP_TYPE_VIS map; - template friend class _LIBCPP_TYPE_VIS multimap; - template friend class _LIBCPP_TYPE_VIS set; - template friend class _LIBCPP_TYPE_VIS multiset; - template friend class _LIBCPP_TYPE_VIS __map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY map; + template friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY set; + template friend class _LIBCPP_TYPE_VIS_ONLY multiset; + template friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template @@ -1107,8 +1116,8 @@ private: __node_pointer __detach(); static __node_pointer __detach(__node_pointer); - template friend class _LIBCPP_TYPE_VIS map; - template friend class _LIBCPP_TYPE_VIS multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY map; + template friend class _LIBCPP_TYPE_VIS_ONLY multimap; }; template @@ -1845,7 +1854,7 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v) __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/contrib/libc++/include/__tuple b/contrib/libc++/include/__tuple index 1213262da..de35cb87e 100644 --- a/contrib/libc++/include/__tuple +++ b/contrib/libc++/include/__tuple @@ -27,46 +27,46 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS tuple_size; +template class _LIBCPP_TYPE_VIS_ONLY tuple_size; template -class _LIBCPP_TYPE_VIS tuple_size +class _LIBCPP_TYPE_VIS_ONLY tuple_size : public tuple_size<_Tp> {}; template -class _LIBCPP_TYPE_VIS tuple_size +class _LIBCPP_TYPE_VIS_ONLY tuple_size : public tuple_size<_Tp> {}; template -class _LIBCPP_TYPE_VIS tuple_size +class _LIBCPP_TYPE_VIS_ONLY tuple_size : public tuple_size<_Tp> {}; -template class _LIBCPP_TYPE_VIS tuple_element; +template class _LIBCPP_TYPE_VIS_ONLY tuple_element; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const _Tp> { public: typedef typename add_const::type>::type type; }; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, volatile _Tp> { public: typedef typename add_volatile::type>::type type; }; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const volatile _Tp> { public: typedef typename add_cv::type>::type type; }; -template class _LIBCPP_TYPE_VIS tuple; -template struct _LIBCPP_TYPE_VIS pair; -template struct _LIBCPP_TYPE_VIS array; +template class _LIBCPP_TYPE_VIS_ONLY tuple; +template struct _LIBCPP_TYPE_VIS_ONLY pair; +template struct _LIBCPP_TYPE_VIS_ONLY array; template struct __tuple_like : false_type {}; @@ -79,47 +79,47 @@ template struct __tuple_like > : true_type template struct __tuple_like > : true_type {}; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type& get(tuple<_Tp...>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, tuple<_Tp...> >::type& get(const tuple<_Tp...>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(pair<_T1, _T2>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; @@ -154,7 +154,7 @@ struct __make_tuple_indices template struct __tuple_types {}; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, __tuple_types<> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<> > { public: static_assert(_Ip == 0, "tuple_element index out of range"); @@ -162,21 +162,21 @@ public: }; template -class _LIBCPP_TYPE_VIS tuple_element<0, __tuple_types<_Hp, _Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, __tuple_types<_Hp, _Tp...> > { public: typedef _Hp type; }; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, __tuple_types<_Hp, _Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Hp, _Tp...> > { public: typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...> >::type type; }; template -class _LIBCPP_TYPE_VIS tuple_size<__tuple_types<_Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> > : public integral_constant { }; diff --git a/contrib/libc++/include/__tuple_03 b/contrib/libc++/include/__tuple_03 index 605d84df1..b91c2cd48 100644 --- a/contrib/libc++/include/__tuple_03 +++ b/contrib/libc++/include/__tuple_03 @@ -19,8 +19,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS tuple_size; -template class _LIBCPP_TYPE_VIS tuple_element; +template class _LIBCPP_TYPE_VIS_ONLY tuple_size; +template class _LIBCPP_TYPE_VIS_ONLY tuple_element; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/__undef_min_max b/contrib/libc++/include/__undef_min_max index b1e80d1b0..5df9412c6 100644 --- a/contrib/libc++/include/__undef_min_max +++ b/contrib/libc++/include/__undef_min_max @@ -9,11 +9,21 @@ //===----------------------------------------------------------------------===// #ifdef min +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " + "before any Windows header. #undefing min") +#else #warning: macro min is incompatible with C++. #undefing min +#endif #undef min #endif #ifdef max +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " + "before any Windows header. #undefing max") +#else #warning: macro max is incompatible with C++. #undefing max +#endif #undef max #endif diff --git a/contrib/libc++/include/algorithm b/contrib/libc++/include/algorithm index 703a9b3dc..367489fbb 100644 --- a/contrib/libc++/include/algorithm +++ b/contrib/libc++/include/algorithm @@ -628,6 +628,13 @@ template #include #include +#if defined(__IBMCPP__) +#include "support/ibm/support.h" +#endif +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include "support/win32/support.h" +#endif + #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -710,7 +717,7 @@ public: bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);} }; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG template struct __debug_less @@ -727,7 +734,7 @@ struct __debug_less } }; -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG // Precondition: __x != 0 inline _LIBCPP_INLINE_VISIBILITY @@ -825,7 +832,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _VSTD::move(__f); + return _VSTD::move(__f); // explicitly moved for (emulated) C++03 } // find @@ -1688,6 +1695,8 @@ __unwrap_iter(move_iterator<_Tp*> __i) return __i.base(); } +#if _LIBCPP_DEBUG_LEVEL < 2 + template inline _LIBCPP_INLINE_VISIBILITY typename enable_if @@ -1700,6 +1709,8 @@ __unwrap_iter(__wrap_iter<_Tp*> __i) return __i.base(); } +#endif // _LIBCPP_DEBUG_LEVEL < 2 + template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator @@ -1987,17 +1998,23 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _ template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, false_type) +__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { for (; __n > 0; ++__first, --__n) *__first = __value_; return __first; } -template +template inline _LIBCPP_INLINE_VISIBILITY -_OutputIterator -__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, true_type) +typename enable_if +< + is_integral<_Tp>::value && sizeof(_Tp) == 1 && + !is_same<_Tp, bool>::value && + is_integral<_Up>::value && sizeof(_Up) == 1, + _Tp* +>::type +__fill_n(_Tp* __first, _Size __n,_Up __value_) { if (__n > 0) _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n)); @@ -2009,10 +2026,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { - return _VSTD::__fill_n(__first, __n, __value_, integral_constant::value && - is_trivially_copy_assignable<_Tp>::value && - sizeof(_Tp) == 1>()); + return _VSTD::__fill_n(__first, __n, __value_); } // fill @@ -2961,11 +2975,11 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p return static_cast(__u + __p.a()); } -class __rs_default; +class _LIBCPP_TYPE_VIS __rs_default; -__rs_default __rs_get(); +_LIBCPP_FUNC_VIS __rs_default __rs_get(); -class __rs_default +class _LIBCPP_TYPE_VIS __rs_default { static unsigned __c_; @@ -2984,10 +2998,10 @@ public: static _LIBCPP_CONSTEXPR result_type min() {return _Min;} static _LIBCPP_CONSTEXPR result_type max() {return _Max;} - friend __rs_default __rs_get(); + friend _LIBCPP_FUNC_VIS __rs_default __rs_get(); }; -__rs_default __rs_get(); +_LIBCPP_FUNC_VIS __rs_default __rs_get(); template void @@ -3942,14 +3956,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -3985,46 +3999,46 @@ sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp) _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp); } -#ifdef _MSC_VER +#ifdef _LIBCPP_MSVC #pragma warning( push ) #pragma warning( disable: 4231) -#endif // _MSC_VER -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, char*>(char*, char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, signed char*>(signed char*, signed char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, short*>(short*, short*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, int*>(int*, int*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, unsigned*>(unsigned*, unsigned*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, long*>(long*, long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, long long*>(long long*, long long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, float*>(float*, float*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, double*>(double*, double*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less&, long double*>(long double*, long double*, __less&)) - -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, int*>(int*, int*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, unsigned*>(unsigned*, unsigned*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, long*>(long*, long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, long long*>(long long*, long long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, float*>(float*, float*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, double*>(double*, double*, __less&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&)) - -_LIBCPP_EXTERN_TEMPLATE(unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&)) -#ifdef _MSC_VER +#endif // _LIBCPP_MSVC +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, char*>(char*, char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, signed char*>(signed char*, signed char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, short*>(short*, short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, int*>(int*, int*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned*>(unsigned*, unsigned*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long*>(long*, long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long long*>(long long*, long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, float*>(float*, float*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, double*>(double*, double*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long double*>(long double*, long double*, __less&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, int*>(int*, int*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned*>(unsigned*, unsigned*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long*>(long*, long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long long*>(long long*, long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, float*>(float*, float*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, double*>(double*, double*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&)) +#ifdef _LIBCPP_MSVC #pragma warning( pop ) -#endif // _MSC_VER +#endif // _LIBCPP_MSVC // lower_bound @@ -4055,14 +4069,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lower_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4103,14 +4117,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __upper_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4163,14 +4177,14 @@ inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __equal_range<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4198,14 +4212,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __binary_search<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4248,14 +4262,14 @@ _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4422,16 +4436,16 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ __buf = _VSTD::get_temporary_buffer(__buf_size); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4633,14 +4647,14 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar __buf = _VSTD::get_temporary_buffer(__len); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4782,14 +4796,14 @@ inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#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); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4820,14 +4834,14 @@ inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4860,14 +4874,14 @@ inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __make_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __make_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4894,14 +4908,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4938,14 +4952,14 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __partial_sort<_Comp_ref>(__first, __middle, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -4988,14 +5002,14 @@ _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5202,14 +5216,14 @@ inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __nth_element<_Comp_ref>(__first, __nth, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __nth_element<_Comp_ref>(__first, __nth, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5243,14 +5257,14 @@ bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5296,14 +5310,14 @@ _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5348,14 +5362,14 @@ _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5402,14 +5416,14 @@ _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5461,14 +5475,14 @@ _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5505,14 +5519,14 @@ bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5560,14 +5574,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __next_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __next_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template @@ -5613,14 +5627,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __prev_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __prev_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template diff --git a/contrib/libc++/include/array b/contrib/libc++/include/array index bcf534786..d37075da1 100644 --- a/contrib/libc++/include/array +++ b/contrib/libc++/include/array @@ -59,14 +59,14 @@ struct array // element access: reference operator[](size_type n); - const_reference operator[](size_type n) const; - const_reference at(size_type n) const; + const_reference operator[](size_type n) const; // constexpr in C++14 + const_reference at(size_type n) const; // constexpr in C++14 reference at(size_type n); reference front(); - const_reference front() const; + const_reference front() const; // constexpr in C++14 reference back(); - const_reference back() const; + const_reference back() const; // constexpr in C++14 T* data() noexcept; const T* data() const noexcept; @@ -92,9 +92,9 @@ template class tuple_size; template class tuple_element; template struct tuple_size>; template struct tuple_element>; -template T& get(array&) noexcept; -template const T& get(const array&) noexcept; -template T&& get(array&&) noexcept; +template T& get(array&) noexcept; // constexpr in C++14 +template const T& get(const array&) noexcept; // constexpr in C++14 +template T&& get(array&&) noexcept; // constexpr in C++14 } // std @@ -118,7 +118,7 @@ template T&& get(array&&) noexcept; _LIBCPP_BEGIN_NAMESPACE_STD template -struct _LIBCPP_TYPE_VIS array +struct _LIBCPP_TYPE_VIS_ONLY array { // types: typedef array __self; @@ -181,14 +181,14 @@ struct _LIBCPP_TYPE_VIS array // element access: _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];} - _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __elems_[__n];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];} reference at(size_type __n); - const_reference at(size_type __n) const; + _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; _LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];} - _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __elems_[0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];} _LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} - _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return __elems_;} @@ -210,6 +210,7 @@ array<_Tp, _Size>::at(size_type __n) } template +_LIBCPP_CONSTEXPR_AFTER_CXX11 typename array<_Tp, _Size>::const_reference array<_Tp, _Size>::at(size_type __n) const { @@ -223,7 +224,7 @@ array<_Tp, _Size>::at(size_type __n) const } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -231,7 +232,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -239,7 +240,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -247,7 +248,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -255,7 +256,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -263,7 +264,7 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -271,7 +272,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_swappable<_Tp>::value, @@ -284,54 +285,54 @@ swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template -class _LIBCPP_TYPE_VIS tuple_size > +class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; template -class _LIBCPP_TYPE_VIS tuple_size > +class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> > { public: typedef _Tp type; }; template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const array<_Tp, _Size> > { public: typedef const _Tp type; }; template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT { static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)"); - return __a[_Ip]; + return __a.__elems_[_Ip]; } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT { static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)"); - return __a[_Ip]; + return __a.__elems_[_Ip]; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT { static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)"); - return _VSTD::move(__a[_Ip]); + return _VSTD::move(__a.__elems_[_Ip]); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/contrib/libc++/include/bitset b/contrib/libc++/include/bitset index dd9be4fcb..4cc7dbdae 100644 --- a/contrib/libc++/include/bitset +++ b/contrib/libc++/include/bitset @@ -632,11 +632,11 @@ __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT { } -template class _LIBCPP_TYPE_VIS bitset; -template struct _LIBCPP_TYPE_VIS hash >; +template class _LIBCPP_TYPE_VIS_ONLY bitset; +template struct _LIBCPP_TYPE_VIS_ONLY hash >; template -class _LIBCPP_TYPE_VIS bitset +class _LIBCPP_TYPE_VIS_ONLY bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { public: @@ -1060,7 +1060,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT } template -struct _LIBCPP_TYPE_VIS hash > +struct _LIBCPP_TYPE_VIS_ONLY hash > : public unary_function, size_t> { _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/cctype b/contrib/libc++/include/cctype index e33244e7d..b647903c4 100644 --- a/contrib/libc++/include/cctype +++ b/contrib/libc++/include/cctype @@ -37,9 +37,9 @@ int toupper(int c); #include <__config> #include -#if defined(_MSC_VER) +#if defined(_LIBCPP_MSVCRT) #include "support/win32/support.h" -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/contrib/libc++/include/chrono b/contrib/libc++/include/chrono index 4ceb875c3..2c65eee7d 100644 --- a/contrib/libc++/include/chrono +++ b/contrib/libc++/include/chrono @@ -111,16 +111,16 @@ private: duration d_; // exposition only public: - time_point(); // has value "epoch" - explicit time_point(const duration& d); // same as time_point() + d + time_point(); // has value "epoch" // constexpr in C++14 + explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14 // conversions template - time_point(const time_point& t); + time_point(const time_point& t); // constexpr in C++14 // observer - duration time_since_epoch() const; + duration time_since_epoch() const; // constexpr in C++14 // arithmetic @@ -194,7 +194,7 @@ template template ToDuration duration_cast(const duration& d); -// time_point arithmetic +// time_point arithmetic (all constexpr in C++14) template time_point>::type> operator+(const time_point& lhs, const duration& rhs); @@ -208,7 +208,7 @@ template typename common_type::type operator-(const time_point& lhs, const time_point& rhs); -// time_point comparisons +// time_point comparisons (all constexpr in C++14) template bool operator==(const time_point& lhs, const time_point& rhs); template @@ -222,7 +222,7 @@ template template bool operator>=(const time_point& lhs, const time_point& rhs); -// time_point_cast +// time_point_cast (constexpr in C++14) template time_point time_point_cast(const time_point& t); @@ -236,7 +236,7 @@ public: typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; - static const bool is_steady = false; + static const bool is_steady = false; // constexpr in C++14 static time_point now() noexcept; static time_t to_time_t (const time_point& __t) noexcept; @@ -250,7 +250,7 @@ public: typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; - static const bool is_steady = true; + static const bool is_steady = true; // constexpr in C++14 static time_point now() noexcept; }; @@ -259,6 +259,19 @@ typedef steady_clock high_resolution_clock; } // chrono +constexpr chrono::hours operator "" h(unsigned long long); // C++14 +constexpr chrono::duration> operator "" h(long double); // C++14 +constexpr chrono::minutes operator "" min(unsigned long long); // C++14 +constexpr chrono::duration> operator "" min(long double); // C++14 +constexpr chrono::seconds operator "" s(unsigned long long); // C++14 +constexpr chrono::duration operator "" s(long double); // C++14 +constexpr chrono::milliseconds operator "" ms(unsigned long long); // C++14 +constexpr chrono::duration operator "" ms(long double); // C++14 +constexpr chrono::microseconds operator "" us(unsigned long long); // C++14 +constexpr chrono::duration operator "" us(long double); // C++14 +constexpr chrono::nanoseconds operator "" ns(unsigned long long); // C++14 +constexpr chrono::duration operator "" ns(long double); // C++14 + } // std */ @@ -279,7 +292,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { -template > class _LIBCPP_TYPE_VIS duration; +template > class _LIBCPP_TYPE_VIS_ONLY duration; template struct __is_duration : false_type {}; @@ -299,8 +312,8 @@ struct __is_duration > : true_type {}; } // chrono template -struct _LIBCPP_TYPE_VIS common_type, - chrono::duration<_Rep2, _Period2> > +struct _LIBCPP_TYPE_VIS_ONLY common_type, + chrono::duration<_Rep2, _Period2> > { typedef chrono::duration::type, typename __ratio_gcd<_Period1, _Period2>::type> type; @@ -377,10 +390,10 @@ duration_cast(const duration<_Rep, _Period>& __fd) } template -struct _LIBCPP_TYPE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; +struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {}; template -struct _LIBCPP_TYPE_VIS duration_values +struct _LIBCPP_TYPE_VIS_ONLY duration_values { public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);} @@ -391,11 +404,42 @@ public: // duration template -class _LIBCPP_TYPE_VIS duration +class _LIBCPP_TYPE_VIS_ONLY duration { static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(_Period::num > 0, "duration period must be positive"); + + template + struct __no_overflow + { + private: + static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; + static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; + static const intmax_t __n1 = _R1::num / __gcd_n1_n2; + static const intmax_t __d1 = _R1::den / __gcd_d1_d2; + static const intmax_t __n2 = _R2::num / __gcd_n1_n2; + static const intmax_t __d2 = _R2::den / __gcd_d1_d2; + static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); + + template + struct __mul // __overflow == false + { + static const intmax_t value = _Xp * _Yp; + }; + + template + struct __mul<_Xp, _Yp, true> + { + static const intmax_t value = 1; + }; + + public: + static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); + typedef ratio<__mul<__n1, __d2, !value>::value, + __mul<__n2, __d1, !value>::value> type; + }; + public: typedef _Rep rep; typedef _Period period; @@ -403,7 +447,13 @@ private: rep __rep_; public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration() {} // = default; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + duration() = default; +#else + duration() {} +#endif + template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit duration(const _Rep2& __r, @@ -421,9 +471,10 @@ public: duration(const duration<_Rep2, _Period2>& __d, typename enable_if < + __no_overflow<_Period2, period>::value && ( treat_as_floating_point::value || - (ratio_divide<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value) + (__no_overflow<_Period2, period>::type::den == 1 && + !treat_as_floating_point<_Rep2>::value)) >::type* = 0) : __rep_(_VSTD::chrono::duration_cast(__d).count()) {} @@ -696,7 +747,7 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 ////////////////////////////////////////////////////////// template -class _LIBCPP_TYPE_VIS time_point +class _LIBCPP_TYPE_VIS_ONLY time_point { static_assert(__is_duration<_Duration>::value, "Second template parameter of time_point must be a std::chrono::duration"); @@ -709,12 +760,12 @@ private: duration __d_; public: - _LIBCPP_INLINE_VISIBILITY time_point() : __d_(duration::zero()) {} - _LIBCPP_INLINE_VISIBILITY explicit time_point(const duration& __d) : __d_(__d) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} // conversions template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point(const time_point& t, typename enable_if < @@ -724,12 +775,12 @@ public: // observer - _LIBCPP_INLINE_VISIBILITY duration time_since_epoch() const {return __d_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} // arithmetic - _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} - _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} + _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} + _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} // special values @@ -740,8 +791,8 @@ public: } // chrono template -struct _LIBCPP_TYPE_VIS common_type, - chrono::time_point<_Clock, _Duration2> > +struct _LIBCPP_TYPE_VIS_ONLY common_type, + chrono::time_point<_Clock, _Duration2> > { typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; }; @@ -749,7 +800,7 @@ struct _LIBCPP_TYPE_VIS common_type, namespace chrono { template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, _ToDuration> time_point_cast(const time_point<_Clock, _Duration>& __t) { @@ -759,7 +810,7 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) // time_point == template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -769,7 +820,7 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point != template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -779,7 +830,7 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point < template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -789,7 +840,7 @@ operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point > template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -799,7 +850,7 @@ operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point <= template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -809,7 +860,7 @@ operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point >= template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -819,20 +870,18 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, // time_point operator+(time_point x, duration y); template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; - _Tr __r(__lhs.time_since_epoch()); - __r += __rhs; - return __r; + return _Tr (__lhs.time_since_epoch() + __rhs); } // time_point operator+(duration x, time_point y); template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type, _Duration2>::type> operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -842,7 +891,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura // time_point operator-(time_point x, duration y); template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { @@ -852,7 +901,7 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe // duration operator-(time_point x, time_point y); template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename common_type<_Duration1, _Duration2>::type operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { @@ -870,7 +919,7 @@ public: typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; - static const bool is_steady = false; + static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; static time_point now() _NOEXCEPT; static time_t to_time_t (const time_point& __t) _NOEXCEPT; @@ -884,7 +933,7 @@ public: typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point time_point; - static const bool is_steady = true; + static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; static time_point now() _NOEXCEPT; }; @@ -893,6 +942,86 @@ typedef steady_clock high_resolution_clock; } // chrono +#if _LIBCPP_STD_VER > 11 +// Suffixes for duration literals [time.duration.literals] +inline namespace literals +{ + inline namespace chrono_literals + { + + constexpr chrono::hours operator"" h(unsigned long long __h) + { + return chrono::hours(static_cast(__h)); + } + + constexpr chrono::duration> operator"" h(long double __h) + { + return chrono::duration>(__h); + } + + + constexpr chrono::minutes operator"" min(unsigned long long __m) + { + return chrono::minutes(static_cast(__m)); + } + + constexpr chrono::duration> operator"" min(long double __m) + { + return chrono::duration> (__m); + } + + + constexpr chrono::seconds operator"" s(unsigned long long __s) + { + return chrono::seconds(static_cast(__s)); + } + + constexpr chrono::duration operator"" s(long double __s) + { + return chrono::duration (__s); + } + + + constexpr chrono::milliseconds operator"" ms(unsigned long long __ms) + { + return chrono::milliseconds(static_cast(__ms)); + } + + constexpr chrono::duration operator"" ms(long double __ms) + { + return chrono::duration(__ms); + } + + + constexpr chrono::microseconds operator"" us(unsigned long long __us) + { + return chrono::microseconds(static_cast(__us)); + } + + constexpr chrono::duration operator"" us(long double __us) + { + return chrono::duration (__us); + } + + + constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns) + { + return chrono::nanoseconds(static_cast(__ns)); + } + + constexpr chrono::duration operator"" ns(long double __ns) + { + return chrono::duration (__ns); + } + +}} + +namespace chrono { // hoist the literals into namespace std::chrono + using namespace literals::chrono_literals; +} + +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CHRONO diff --git a/contrib/libc++/include/cmath b/contrib/libc++/include/cmath index bd6034413..75087ae78 100644 --- a/contrib/libc++/include/cmath +++ b/contrib/libc++/include/cmath @@ -301,7 +301,7 @@ long double truncl(long double x); #include #include -#ifdef _MSC_VER +#ifdef _LIBCPP_MSVCRT #include "support/win32/math_win32.h" #endif @@ -654,6 +654,7 @@ using ::double_t; // abs +#if !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY float abs(float __x) _NOEXCEPT {return fabsf(__x);} @@ -665,6 +666,7 @@ abs(double __x) _NOEXCEPT {return fabs(__x);} inline _LIBCPP_INLINE_VISIBILITY long double abs(long double __x) _NOEXCEPT {return fabsl(__x);} +#endif // !defined(_AIX) #ifndef __sun__ @@ -673,7 +675,7 @@ abs(long double __x) _NOEXCEPT {return fabsl(__x);} using ::acos; using ::acosf; -#ifndef _MSC_VER +#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);} #endif @@ -688,7 +690,7 @@ acos(_A1 __x) _NOEXCEPT {return acos((double)__x);} using ::asin; using ::asinf; -#ifndef _MSC_VER +#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);} #endif @@ -703,7 +705,7 @@ asin(_A1 __x) _NOEXCEPT {return asin((double)__x);} using ::atan; using ::atanf; -#ifndef _MSC_VER +#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);} #endif @@ -718,7 +720,7 @@ atan(_A1 __x) _NOEXCEPT {return atan((double)__x);} using ::atan2; using ::atan2f; -#ifndef _MSC_VER +#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);} #endif @@ -744,7 +746,7 @@ atan2(_A1 __y, _A2 __x) _NOEXCEPT using ::ceil; using ::ceilf; -#ifndef _MSC_VER +#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);} #endif @@ -759,13 +761,13 @@ ceil(_A1 __x) _NOEXCEPT {return ceil((double)__x);} using ::cos; using ::cosf; -#ifndef _MSC_VER +#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);} #endif template -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} @@ -774,7 +776,7 @@ cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} using ::cosh; using ::coshf; -#ifndef _MSC_VER +#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);} #endif @@ -792,7 +794,7 @@ using ::expf; #ifndef __sun__ -#ifndef _MSC_VER +#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);} #endif @@ -808,7 +810,7 @@ exp(_A1 __x) _NOEXCEPT {return exp((double)__x);} using ::fabs; using ::fabsf; -#ifndef _MSC_VER +#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);} #endif @@ -823,7 +825,7 @@ fabs(_A1 __x) _NOEXCEPT {return fabs((double)__x);} using ::floor; using ::floorf; -#ifndef _MSC_VER +#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);} #endif @@ -840,7 +842,7 @@ using ::fmod; using ::fmodf; #ifndef __sun__ -#ifndef _MSC_VER +#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);} #endif @@ -867,7 +869,7 @@ fmod(_A1 __x, _A2 __y) _NOEXCEPT using ::frexp; using ::frexpf; -#ifndef _MSC_VER +#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);} #endif @@ -882,7 +884,7 @@ frexp(_A1 __x, int* __e) _NOEXCEPT {return frexp((double)__x, __e);} using ::ldexp; using ::ldexpf; -#ifndef _MSC_VER +#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);} #endif @@ -899,7 +901,7 @@ using ::log; using ::logf; #ifndef __sun__ -#ifndef _MSC_VER +#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);} #endif @@ -915,7 +917,7 @@ log(_A1 __x) _NOEXCEPT {return log((double)__x);} using ::log10; using ::log10f; -#ifndef _MSC_VER +#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);} #endif @@ -930,7 +932,7 @@ log10(_A1 __x) _NOEXCEPT {return log10((double)__x);} using ::modf; using ::modff; -#ifndef _MSC_VER +#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);} #endif @@ -943,7 +945,7 @@ using ::powf; #ifndef __sun__ -#ifndef _MSC_VER +#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);} #endif @@ -970,7 +972,7 @@ pow(_A1 __x, _A2 __y) _NOEXCEPT using ::sin; using ::sinf; -#ifndef _MSC_VER +#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);} #endif @@ -985,7 +987,7 @@ sin(_A1 __x) _NOEXCEPT {return sin((double)__x);} using ::sinh; using ::sinhf; -#ifndef _MSC_VER +#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);} #endif @@ -1002,7 +1004,7 @@ using ::sqrt; using ::sqrtf; -#if !(defined(_MSC_VER) || defined(__sun__)) +#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);} #endif @@ -1018,7 +1020,7 @@ using ::tan; using ::tanf; #ifndef __sun__ -#ifndef _MSC_VER +#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);} #endif @@ -1033,7 +1035,7 @@ tan(_A1 __x) _NOEXCEPT {return tan((double)__x);} using ::tanh; using ::tanhf; -#ifndef _MSC_VER +#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);} #endif @@ -1045,7 +1047,7 @@ tanh(_A1 __x) _NOEXCEPT {return tanh((double)__x);} // acosh -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::acosh; using ::acoshf; @@ -1060,7 +1062,7 @@ acosh(_A1 __x) _NOEXCEPT {return acosh((double)__x);} // asinh -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::asinh; using ::asinhf; @@ -1075,7 +1077,7 @@ asinh(_A1 __x) _NOEXCEPT {return asinh((double)__x);} // atanh -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::atanh; using ::atanhf; @@ -1090,7 +1092,7 @@ atanh(_A1 __x) _NOEXCEPT {return atanh((double)__x);} // cbrt -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::cbrt; using ::cbrtf; @@ -1127,7 +1129,7 @@ copysign(_A1 __x, _A2 __y) _NOEXCEPT return copysign((__result_type)__x, (__result_type)__y); } -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT // erf @@ -1426,13 +1428,18 @@ inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, long>::type lround(_A1 __x) _NOEXCEPT {return lround((double)__x);} -// nan -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT #endif // __sun__ + +// nan + +#ifndef _LIBCPP_MSVCRT using ::nan; using ::nanf; +#endif // _LIBCPP_MSVCRT + #ifndef __sun__ -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT // nearbyint @@ -1610,7 +1617,7 @@ inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type trunc(_A1 __x) _NOEXCEPT {return trunc((double)__x);} -#endif // !_MSC_VER +#endif // !_LIBCPP_MSVCRT using ::acosl; using ::asinl; @@ -1633,15 +1640,15 @@ using ::sinl; using ::sinhl; using ::sqrtl; using ::tanl; -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::tanhl; using ::acoshl; using ::asinhl; using ::atanhl; using ::cbrtl; -#endif // !_MSC_VER +#endif // !_LIBCPP_MSVCRT using ::copysignl; -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::erfl; using ::erfcl; using ::exp2l; @@ -1672,7 +1679,7 @@ using ::scalblnl; using ::scalbnl; using ::tgammal; using ::truncl; -#endif // !_MSC_VER +#endif // !_LIBCPP_MSVCRT #else using ::lgamma; diff --git a/contrib/libc++/include/codecvt b/contrib/libc++/include/codecvt index a6e4308e2..6eff107cd 100644 --- a/contrib/libc++/include/codecvt +++ b/contrib/libc++/include/codecvt @@ -29,7 +29,8 @@ template { - // unspecified + explicit codecvt_utf8(size_t refs = 0); + ~codecvt_utf8(); }; template { - // unspecified + explicit codecvt_utf16(size_t refs = 0); + ~codecvt_utf16(); }; template { - // unspecified + explicit codecvt_utf8_utf16(size_t refs = 0); + ~codecvt_utf8_utf16(); }; } // std @@ -73,7 +76,7 @@ enum codecvt_mode template class __codecvt_utf8; template <> -class __codecvt_utf8 +class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; @@ -108,7 +111,7 @@ protected: }; template <> -class __codecvt_utf8 +class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; @@ -143,7 +146,7 @@ protected: }; template <> -class __codecvt_utf8 +class _LIBCPP_TYPE_VIS __codecvt_utf8 : public codecvt { unsigned long _Maxcode_; @@ -179,7 +182,7 @@ protected: template -class _LIBCPP_TYPE_VIS codecvt_utf8 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8 : public __codecvt_utf8<_Elem> { public: @@ -196,7 +199,7 @@ public: template class __codecvt_utf16; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -231,7 +234,7 @@ protected: }; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -266,7 +269,7 @@ protected: }; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -301,7 +304,7 @@ protected: }; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -336,7 +339,7 @@ protected: }; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -371,7 +374,7 @@ protected: }; template <> -class __codecvt_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf16 : public codecvt { unsigned long _Maxcode_; @@ -407,7 +410,7 @@ protected: template -class _LIBCPP_TYPE_VIS codecvt_utf16 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { public: @@ -424,7 +427,7 @@ public: template class __codecvt_utf8_utf16; template <> -class __codecvt_utf8_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; @@ -459,7 +462,7 @@ protected: }; template <> -class __codecvt_utf8_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; @@ -494,7 +497,7 @@ protected: }; template <> -class __codecvt_utf8_utf16 +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16 : public codecvt { unsigned long _Maxcode_; @@ -530,7 +533,7 @@ protected: template -class _LIBCPP_TYPE_VIS codecvt_utf8_utf16 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { public: diff --git a/contrib/libc++/include/complex b/contrib/libc++/include/complex index a09bf70f2..2943da1d7 100644 --- a/contrib/libc++/include/complex +++ b/contrib/libc++/include/complex @@ -23,12 +23,12 @@ class complex public: typedef T value_type; - complex(const T& re = T(), const T& im = T()); - complex(const complex&); - template complex(const complex&); + complex(const T& re = T(), const T& im = T()); // constexpr in C++14 + complex(const complex&); // constexpr in C++14 + template complex(const complex&); // constexpr in C++14 - T real() const; - T imag() const; + T real() const; // constexpr in C++14 + T imag() const; // constexpr in C++14 void real(T); void imag(T); @@ -149,12 +149,12 @@ template complex operator/(const complex&, const T&); template complex operator/(const T&, const complex&); template complex operator+(const complex&); template complex operator-(const complex&); -template bool operator==(const complex&, const complex&); -template bool operator==(const complex&, const T&); -template bool operator==(const T&, const complex&); -template bool operator!=(const complex&, const complex&); -template bool operator!=(const complex&, const T&); -template bool operator!=(const T&, const complex&); +template bool operator==(const complex&, const complex&); // constexpr in C++14 +template bool operator==(const complex&, const T&); // constexpr in C++14 +template bool operator==(const T&, const complex&); // constexpr in C++14 +template bool operator!=(const complex&, const complex&); // constexpr in C++14 +template bool operator!=(const complex&, const T&); // constexpr in C++14 +template bool operator!=(const T&, const complex&); // constexpr in C++14 template basic_istream& @@ -165,17 +165,17 @@ template // 26.3.7 values: -template T real(const complex&); - long double real(long double); - double real(double); -template double real(T); - float real(float); +template T real(const complex&); // constexpr in C++14 + long double real(long double); // constexpr in C++14 + double real(double); // constexpr in C++14 +template double real(T); // constexpr in C++14 + float real(float); // constexpr in C++14 -template T imag(const complex&); - long double imag(long double); - double imag(double); -template double imag(T); - float imag(float); +template T imag(const complex&); // constexpr in C++14 + long double imag(long double); // constexpr in C++14 + double imag(double); // constexpr in C++14 +template double imag(T); // constexpr in C++14 + float imag(float); // constexpr in C++14 template T abs(const complex&); @@ -255,13 +255,13 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS complex; +template class _LIBCPP_TYPE_VIS_ONLY complex; template complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); template complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); template -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { public: typedef _Tp value_type; @@ -269,15 +269,15 @@ private: value_type __re_; value_type __im_; public: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const value_type& __re = value_type(), const value_type& __im = value_type()) : __re_(__re), __im_(__im) {} - template _LIBCPP_INLINE_VISIBILITY + template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const complex<_Xp>& __c) : __re_(__c.real()), __im_(__c.imag()) {} - _LIBCPP_INLINE_VISIBILITY value_type real() const {return __re_;} - _LIBCPP_INLINE_VISIBILITY value_type imag() const {return __im_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} @@ -309,21 +309,21 @@ public: } template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; -template<> class _LIBCPP_TYPE_VIS complex; -template<> class _LIBCPP_TYPE_VIS complex; +template<> class _LIBCPP_TYPE_VIS_ONLY complex; +template<> class _LIBCPP_TYPE_VIS_ONLY complex; template<> -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { float __re_; float __im_; @@ -368,18 +368,18 @@ public: } template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; template<> -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { double __re_; double __im_; @@ -424,18 +424,18 @@ public: } template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; template<> -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { long double __re_; long double __im_; @@ -480,12 +480,12 @@ public: } template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; @@ -740,7 +740,7 @@ operator-(const complex<_Tp>& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -748,7 +748,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const complex<_Tp>& __x, const _Tp& __y) { @@ -756,7 +756,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const _Tp& __x, const complex<_Tp>& __y) { @@ -764,7 +764,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -772,7 +772,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { @@ -780,7 +780,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { @@ -792,21 +792,21 @@ operator!=(const _Tp& __x, const complex<_Tp>& __y) // real template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp real(const complex<_Tp>& __c) { return __c.real(); } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 long double real(long double __re) { return __re; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 double real(double __re) { @@ -814,7 +814,7 @@ real(double __re) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename enable_if < is_integral<_Tp>::value, @@ -825,7 +825,7 @@ real(_Tp __re) return __re; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 float real(float __re) { @@ -835,21 +835,21 @@ real(float __re) // imag template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp imag(const complex<_Tp>& __c) { return __c.imag(); } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 long double imag(long double __re) { return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 double imag(double __re) { @@ -857,7 +857,7 @@ imag(double __re) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename enable_if < is_integral<_Tp>::value, @@ -868,7 +868,7 @@ imag(_Tp __re) return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 float imag(float __re) { @@ -1521,6 +1521,47 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) return __os << __s.str(); } +#if _LIBCPP_STD_VER > 11 +// Literal suffix for complex number literals [complex.literals] +inline namespace literals +{ + inline namespace complex_literals + { + constexpr complex operator""il(long double __im) + { + return { 0.0l, __im }; + } + + constexpr complex operator""il(unsigned long long __im) + { + return { 0.0l, static_cast(__im) }; + } + + + constexpr complex operator""i(long double __im) + { + return { 0.0, static_cast(__im) }; + } + + constexpr complex operator""i(unsigned long long __im) + { + return { 0.0, static_cast(__im) }; + } + + + constexpr complex operator""if(long double __im) + { + return { 0.0f, static_cast(__im) }; + } + + constexpr complex operator""if(unsigned long long __im) + { + return { 0.0f, static_cast(__im) }; + } + } +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_COMPLEX diff --git a/contrib/libc++/include/cstddef b/contrib/libc++/include/cstddef index c26377216..7ef16ff2a 100644 --- a/contrib/libc++/include/cstddef +++ b/contrib/libc++/include/cstddef @@ -56,7 +56,7 @@ typedef long double max_align_t; #ifdef _LIBCPP_HAS_NO_NULLPTR -struct _LIBCPP_TYPE_VIS nullptr_t +struct _LIBCPP_TYPE_VIS_ONLY nullptr_t { void* __lx; diff --git a/contrib/libc++/include/cstdio b/contrib/libc++/include/cstdio index 718d2f715..ce3af4d91 100644 --- a/contrib/libc++/include/cstdio +++ b/contrib/libc++/include/cstdio @@ -74,7 +74,7 @@ int fputc(int c, FILE* stream); int fputs(const char* restrict s, FILE* restrict stream); int getc(FILE* stream); int getchar(void); -char* gets(char* s); +char* gets(char* s); // removed in C++14 int putc(int c, FILE* stream); int putchar(int c); int puts(const char* s); @@ -103,6 +103,11 @@ void perror(const char* s); #pragma GCC system_header #endif +// snprintf +#if defined(_LIBCPP_MSVCRT) +#include "support/win32/support.h" +#endif + #ifdef getc inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);} #undef getc @@ -138,12 +143,12 @@ using ::scanf; using ::snprintf; using ::sprintf; using ::sscanf; -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::vfprintf; using ::vfscanf; using ::vscanf; using ::vsscanf; -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT using ::vprintf; using ::vsnprintf; using ::vsprintf; @@ -153,7 +158,9 @@ using ::fputc; using ::fputs; using ::getc; using ::getchar; +#if _LIBCPP_STD_VER <= 11 using ::gets; +#endif using ::putc; using ::putchar; using ::puts; diff --git a/contrib/libc++/include/cstdlib b/contrib/libc++/include/cstdlib index 95e384283..152b891de 100644 --- a/contrib/libc++/include/cstdlib +++ b/contrib/libc++/include/cstdlib @@ -84,9 +84,9 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 #include <__config> #include -#ifdef _MSC_VER +#ifdef _LIBCPP_MSVCRT #include "support/win32/locale_win32.h" -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -154,8 +154,8 @@ using ::quick_exit; using ::aligned_alloc; #endif -// MSVC already has the correct prototype in #ifdef __cplusplus -#if !defined(_MSC_VER) && !defined(__sun__) +// MSVCRT already has the correct prototype in #ifdef __cplusplus +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);} #ifndef _LIBCPP_HAS_NO_LONG_LONG inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);} @@ -165,7 +165,7 @@ inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEX #ifndef _LIBCPP_HAS_NO_LONG_LONG inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);} #endif // _LIBCPP_HAS_NO_LONG_LONG -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/cstring b/contrib/libc++/include/cstring index 45075b3af..21c9155cd 100644 --- a/contrib/libc++/include/cstring +++ b/contrib/libc++/include/cstring @@ -93,8 +93,8 @@ using ::strspn; using ::strstr; -// MSVC, GNU libc and its derivates already have the correct prototype in #ifdef __cplusplus -#if !defined(__GLIBC__) && !defined(_MSC_VER) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) +// MSVCRT, GNU libc and its derivates already have the correct prototype in #ifdef __cplusplus +#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);} inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);} diff --git a/contrib/libc++/include/cwchar b/contrib/libc++/include/cwchar index 845ccec33..9f51587ca 100644 --- a/contrib/libc++/include/cwchar +++ b/contrib/libc++/include/cwchar @@ -106,9 +106,9 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, #include <__config> #include #include -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include // pull in *swprintf defines -#endif // _WIN32 +#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -127,12 +127,12 @@ using ::swprintf; using ::vfwprintf; using ::vswprintf; using ::vwprintf; -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::swscanf; using ::vfwscanf; using ::vswscanf; using ::vwscanf; -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT using ::wprintf; using ::wscanf; using ::fgetwc; @@ -146,10 +146,10 @@ using ::putwc; using ::putwchar; using ::ungetwc; using ::wcstod; -#ifndef _MSC_VER +#ifndef _LIBCPP_MSVCRT using ::wcstof; using ::wcstold; -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT using ::wcstol; #ifndef _LIBCPP_HAS_NO_LONG_LONG using ::wcstoll; diff --git a/contrib/libc++/include/deque b/contrib/libc++/include/deque index 6c0216d7e..f099000b1 100644 --- a/contrib/libc++/include/deque +++ b/contrib/libc++/include/deque @@ -41,6 +41,7 @@ public: deque() noexcept(is_nothrow_default_constructible::value); explicit deque(const allocator_type& a); explicit deque(size_type n); + explicit deque(size_type n, const allocator_type& a); // C++14 deque(size_type n, const value_type& v); deque(size_type n, const value_type& v, const allocator_type& a); template @@ -170,7 +171,7 @@ template class __deque_base; template -class _LIBCPP_TYPE_VIS __deque_iterator; +class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template @@ -262,7 +263,7 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, template -class _LIBCPP_TYPE_VIS __deque_iterator +class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; public: @@ -278,7 +279,11 @@ public: typedef random_access_iterator_tag iterator_category; typedef _Reference reference; - _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __m_iter_(nullptr), __ptr_(nullptr) +#endif + {} template _LIBCPP_INLINE_VISIBILITY @@ -410,9 +415,9 @@ private: : __m_iter_(__m), __ptr_(__p) {} template friend class __deque_base; - template friend class _LIBCPP_TYPE_VIS deque; + template friend class _LIBCPP_TYPE_VIS_ONLY deque; template - friend class _LIBCPP_TYPE_VIS __deque_iterator; + friend class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template @@ -1174,7 +1179,7 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT } template > -class _LIBCPP_TYPE_VIS deque +class _LIBCPP_TYPE_VIS_ONLY deque : private __deque_base<_Tp, _Allocator> { public: @@ -1205,6 +1210,9 @@ public: {} _LIBCPP_INLINE_VISIBILITY 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); +#endif deque(size_type __n, const value_type& __v); deque(size_type __n, const value_type& __v, const allocator_type& __a); template @@ -1427,6 +1435,16 @@ deque<_Tp, _Allocator>::deque(size_type __n) __append(__n); } +#if _LIBCPP_STD_VER > 11 +template +deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) + : __base(__a) +{ + if (__n > 0) + __append(__n); +} +#endif + template deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) { @@ -2793,7 +2811,7 @@ deque<_Tp, _Allocator>::clear() _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2802,7 +2820,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2810,7 +2828,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2818,7 +2836,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2826,7 +2844,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2834,7 +2852,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2842,7 +2860,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/contrib/libc++/include/exception b/contrib/libc++/include/exception index 37bfc57ef..cad802e05 100644 --- a/contrib/libc++/include/exception +++ b/contrib/libc++/include/exception @@ -118,8 +118,8 @@ _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT; class _LIBCPP_TYPE_VIS exception_ptr; -exception_ptr current_exception() _NOEXCEPT; -_LIBCPP_NORETURN void rethrow_exception(exception_ptr); +_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; +_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); class _LIBCPP_TYPE_VIS exception_ptr { @@ -142,8 +142,8 @@ public: bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return !(__x == __y);} - friend exception_ptr current_exception() _NOEXCEPT; - friend void rethrow_exception(exception_ptr); + friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; + friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); }; template diff --git a/contrib/libc++/include/experimental/dynarray b/contrib/libc++/include/experimental/dynarray new file mode 100644 index 000000000..7c5c9b3f1 --- /dev/null +++ b/contrib/libc++/include/experimental/dynarray @@ -0,0 +1,314 @@ +// -*- C++ -*- +//===-------------------------- dynarray ----------------------------------===// +// +// 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_DYNARRAY +#define _LIBCPP_DYNARRAY + +#include <__config> +#if _LIBCPP_STD_VER > 11 + +/* + dynarray synopsis + +namespace std { namespace experimental { + +template< typename T > +class dynarray +{ + // types: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* pointer; + typedef const T* const_pointer; + typedef implementation-defined iterator; + typedef implementation-defined const_iterator; + typedef reverse_iterator reverse_iterator; + typedef reverse_iterator const_reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +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); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + iterator begin() noexcept; + const_iterator begin() const noexcept; + const_iterator cbegin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; + const_iterator cend() const noexcept; + + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator crbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crend() const noexcept; + + // capacity: + size_type size() const noexcept; + size_type max_size() const noexcept; + bool empty() const noexcept; + + // element access: + reference operator[](size_type n); + const_reference operator[](size_type n) const; + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + const_reference at(size_type n) const; + reference at(size_type n); + + // data access: + T* data() noexcept; + const T* data() const noexcept; + + // mutating member functions: + void fill(const T& v); +}; + +}} // std::experimental + +*/ + +#include <__functional_base> +#include +#include +#include +#include +#include + +#if defined(_LIBCPP_NO_EXCEPTIONS) + #include +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +namespace std { namespace experimental { inline namespace __array_extensions_v1 { + +template +struct _LIBCPP_TYPE_VIS_ONLY dynarray +{ +public: + // types: + typedef dynarray __self; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + +private: + size_t __size_; + value_type * __base_; + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {} + + static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) + { + if ( numeric_limits::max() / sizeof (value_type) <= count ) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_length(); +#else + assert(!"dynarray::allocation"); +#endif + } + return static_cast (::operator new (sizeof(value_type) * count)); + } + + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + { + ::operator delete (static_cast (__ptr)); + } + +public: + + explicit dynarray(size_type __c); + dynarray(size_type __c, const value_type& __v); + dynarray(const dynarray& __d); + dynarray(initializer_list); + +// We're not implementing these right now. +// Waiting for the resolution of LWG issue #2235 +// template +// dynarray(size_type __c, const _Alloc& __alloc); +// template +// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc); +// template +// dynarray(const dynarray& __d, const _Alloc& __alloc); +// template +// dynarray(initializer_list, const _Alloc& __alloc); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); } + + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } + + // capacity: + inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; } + + // element access: + inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; } + + inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; } + + inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const; + inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n); + + // data access: + inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; } + inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; } + + // mutating member functions: + inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); } +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type (__v); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(initializer_list __il) : dynarray () +{ + size_t sz = __il.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __il.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () +{ + size_t sz = __d.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __d.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::~dynarray() +{ + value_type *__data = data () + __size_; + for ( size_t i = 0; i < __size_; ++i ) + (--__data)->value_type::~value_type(); + __deallocate ( __base_ ); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::reference +dynarray<_Tp>::at(size_type __n) +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::const_reference +dynarray<_Tp>::at(size_type __n) const +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +}}} + + +_LIBCPP_BEGIN_NAMESPACE_STD +template +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : true_type {}; +_LIBCPP_END_NAMESPACE_STD + +#endif // if _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_DYNARRAY diff --git a/contrib/libc++/include/experimental/optional b/contrib/libc++/include/experimental/optional new file mode 100644 index 000000000..3848da872 --- /dev/null +++ b/contrib/libc++/include/experimental/optional @@ -0,0 +1,699 @@ +// -*- C++ -*- +//===-------------------------- optional ----------------------------------===// +// +// 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_OPTIONAL +#define _LIBCPP_OPTIONAL + +/* + optional synopsis + +// 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 + +*/ + +#include <__config> +#include +#include + +namespace std { namespace experimental { + +class _LIBCPP_EXCEPTION_ABI bad_optional_access + : public 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 + virtual ~bad_optional_access() _NOEXCEPT; +}; + +}} // std::experimental + +#if _LIBCPP_STD_VER > 11 + +#include +#include +#include +#include <__functional_base> + +#include <__undef_min_max> + +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +namespace std { namespace experimental { inline namespace __library_fundamentals_v1 { + +struct in_place_t {}; +constexpr in_place_t in_place{}; + +struct nullopt_t +{ + explicit constexpr nullopt_t(int) noexcept {} +}; + +constexpr nullopt_t nullopt{0}; + +template ::value> +class __optional_storage +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + ~__optional_storage() + { + if (__engaged_) + __val_.~value_type(); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template +class __optional_storage<_Tp, true> +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template +class optional + : private __optional_storage<_Tp> +{ + typedef __optional_storage<_Tp> __base; +public: + typedef _Tp value_type; + + static_assert(!is_reference::value, + "Instantiation of optional with a reference type is ill-formed."); + static_assert(!is_same::type, in_place_t>::value, + "Instantiation of optional with a in_place_t type is ill-formed."); + static_assert(!is_same::type, nullopt_t>::value, + "Instantiation of optional with a nullopt_t type is ill-formed."); + static_assert(is_object::value, + "Instantiation of optional with a non-object type is undefined behavior."); + static_assert(is_nothrow_destructible::value, + "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior."); + + _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} + _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default; + _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default; + _LIBCPP_INLINE_VISIBILITY ~optional() = default; + _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v) + : __base(__v) {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v) + : __base(_VSTD::move(__v)) {} + + template ::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, _Args&&... __args) + : __base(in_place, _VSTD::forward<_Args>(__args)...) {} + + template &, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + optional& operator=(nullopt_t) noexcept + { + if (this->__engaged_) + { + this->__val_.~value_type(); + this->__engaged_ = false; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(const optional& __opt) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = __opt.__val_; + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(optional&& __opt) + noexcept(is_nothrow_move_assignable::value && + is_nothrow_move_constructible::value) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = _VSTD::move(__opt.__val_); + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + template ::type, value_type>::value && + is_constructible::value && + is_assignable::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(_Up&& __v) + { + if (this->__engaged_) + this->__val_ = _VSTD::forward<_Up>(__v); + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); + this->__engaged_ = true; + } + return *this; + } + + template ::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(_Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + template &, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + _LIBCPP_INLINE_VISIBILITY + void + swap(optional& __opt) + noexcept(is_nothrow_move_constructible::value && + __is_nothrow_swappable::value) + { + using _VSTD::swap; + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + swap(this->__val_, __opt.__val_); + } + else + { + if (this->__engaged_) + { + ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); + this->__val_.~value_type(); + } + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + __opt.__val_.~value_type(); + } + swap(this->__engaged_, __opt.__engaged_); + } + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + operator->() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return __operator_arrow(__has_operator_addressof{}); + } + + _LIBCPP_INLINE_VISIBILITY + value_type* + operator->() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + const value_type& + operator*() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& + operator*() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + constexpr explicit operator bool() const noexcept {return this->__engaged_;} + + _LIBCPP_INLINE_VISIBILITY + constexpr value_type const& value() const + { + if (!this->__engaged_) + throw bad_optional_access("optional::value: not engaged"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& value() + { + if (!this->__engaged_) + throw bad_optional_access("optional::value: not engaged"); + return this->__val_; + } + + template + _LIBCPP_INLINE_VISIBILITY + constexpr value_type value_or(_Up&& __v) const& + { + static_assert(is_copy_constructible::value, + "optional::value_or: T must be copy constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional::value_or: U must be convertible to T"); + return this->__engaged_ ? this->__val_ : + static_cast(_VSTD::forward<_Up>(__v)); + } + + template + _LIBCPP_INLINE_VISIBILITY + value_type value_or(_Up&& __v) && + { + static_assert(is_move_constructible::value, + "optional::value_or: T must be move constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional::value_or: U must be convertible to T"); + return this->__engaged_ ? _VSTD::move(this->__val_) : + static_cast(_VSTD::forward<_Up>(__v)); + } + +private: + _LIBCPP_INLINE_VISIBILITY + value_type const* + __operator_arrow(true_type) const + { + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + __operator_arrow(false_type) const + { + return &this->__val_; + } +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (static_cast(__x) != static_cast(__y)) + return false; + if (!static_cast(__x)) + return true; + return *__x == *__y; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (!static_cast(__y)) + return false; + if (!static_cast(__x)) + return true; + return less<_Tp>{}(*__x, *__y); +} + +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 +bool +operator<(const optional<_Tp>&, nullopt_t) noexcept +{ + return false; +} + +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 +bool +operator==(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast(__x) ? *__x == __v : false; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +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) ? less<_Tp>{}(*__x, __v) : true; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast(__x) ? less<_Tp>{}(__v, *__x) : false; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) +{ + __x.swap(__y); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr +optional::type> +make_optional(_Tp&& __v) +{ + return optional::type>(_VSTD::forward<_Tp>(__v)); +} + +}}} // namespace std::experimental::__library_fundamentals_v1 + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct _LIBCPP_TYPE_VIS_ONLY hash > +{ + typedef std::experimental::optional<_Tp> argument_type; + typedef size_t result_type; + + _LIBCPP_INLINE_VISIBILITY + result_type operator()(const argument_type& __opt) const _NOEXCEPT + { + return static_cast(__opt) ? hash<_Tp>()(*__opt) : 0; + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_ARRAY diff --git a/contrib/libc++/include/ext/__hash b/contrib/libc++/include/ext/__hash index f6ecfe360..c0523cce4 100644 --- a/contrib/libc++/include/ext/__hash +++ b/contrib/libc++/include/ext/__hash @@ -19,10 +19,10 @@ namespace __gnu_cxx { using namespace std; -template struct _LIBCPP_TYPE_VIS hash : public std::hash +template struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<_Tp> { }; -template <> struct _LIBCPP_TYPE_VIS hash +template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -32,7 +32,7 @@ template <> struct _LIBCPP_TYPE_VIS hash } }; -template <> struct _LIBCPP_TYPE_VIS hash +template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/ext/hash_map b/contrib/libc++/include/ext/hash_map index a6fe894e4..225b72baa 100644 --- a/contrib/libc++/include/ext/hash_map +++ b/contrib/libc++/include/ext/hash_map @@ -206,7 +206,11 @@ template #include #if __DEPRECATED -#warning Use of the header is deprecated. Migrate to +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header is deprecated. Migrate to ") +#else +# warning Use of the header is deprecated. Migrate to +#endif #endif #pragma GCC system_header @@ -361,7 +365,7 @@ public: }; template -class _LIBCPP_TYPE_VIS __hash_map_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; @@ -404,15 +408,15 @@ public: bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS hash_map; - template friend class _LIBCPP_TYPE_VIS hash_multimap; - template friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY hash_map; + template friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template -class _LIBCPP_TYPE_VIS __hash_map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; @@ -463,15 +467,15 @@ public: bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS hash_map; - template friend class _LIBCPP_TYPE_VIS hash_multimap; - template friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY hash_map; + template friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; }; template , class _Pred = equal_to<_Key>, class _Alloc = allocator > > -class _LIBCPP_TYPE_VIS hash_map +class _LIBCPP_TYPE_VIS_ONLY hash_map { public: // types @@ -684,7 +688,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template @@ -750,7 +754,7 @@ operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, template , class _Pred = equal_to<_Key>, class _Alloc = allocator > > -class _LIBCPP_TYPE_VIS hash_multimap +class _LIBCPP_TYPE_VIS_ONLY hash_multimap { public: // types diff --git a/contrib/libc++/include/ext/hash_set b/contrib/libc++/include/ext/hash_set index 52bbeee13..c4bb89843 100644 --- a/contrib/libc++/include/ext/hash_set +++ b/contrib/libc++/include/ext/hash_set @@ -199,7 +199,11 @@ template #include #if __DEPRECATED -#warning Use of the header is deprecated. Migrate to +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header is deprecated. Migrate to ") +#else +# warning Use of the header is deprecated. Migrate to +#endif #endif namespace __gnu_cxx { @@ -208,7 +212,7 @@ using namespace std; template , class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS hash_set +class _LIBCPP_TYPE_VIS_ONLY hash_set { public: // types @@ -429,7 +433,7 @@ operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x, template , class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS hash_multiset +class _LIBCPP_TYPE_VIS_ONLY hash_multiset { public: // types diff --git a/contrib/libc++/include/forward_list b/contrib/libc++/include/forward_list index 88bf75f90..398226b8d 100644 --- a/contrib/libc++/include/forward_list +++ b/contrib/libc++/include/forward_list @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible::value); explicit forward_list(const allocator_type& a); explicit forward_list(size_type n); + explicit forward_list(size_type n, const allocator_type& a); // C++14 forward_list(size_type n, const value_type& v); forward_list(size_type n, const value_type& v, const allocator_type& a); template @@ -212,11 +213,11 @@ struct __forward_list_node value_type __value_; }; -template class _LIBCPP_TYPE_VIS forward_list; -template class _LIBCPP_TYPE_VIS __forward_list_const_iterator; +template class _LIBCPP_TYPE_VIS_ONLY forward_list; +template class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template -class _LIBCPP_TYPE_VIS __forward_list_iterator +class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator { typedef _NodePtr __node_pointer; @@ -225,8 +226,8 @@ class _LIBCPP_TYPE_VIS __forward_list_iterator _LIBCPP_INLINE_VISIBILITY explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - template friend class _LIBCPP_TYPE_VIS forward_list; - template friend class _LIBCPP_TYPE_VIS __forward_list_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY forward_list; + template friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; public: typedef forward_iterator_tag iterator_category; @@ -276,7 +277,7 @@ public: }; template -class _LIBCPP_TYPE_VIS __forward_list_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator { typedef _NodeConstPtr __node_const_pointer; @@ -542,7 +543,7 @@ __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT } template > -class _LIBCPP_TYPE_VIS forward_list +class _LIBCPP_TYPE_VIS_ONLY forward_list : private __forward_list_base<_Tp, _Alloc> { typedef __forward_list_base<_Tp, _Alloc> base; @@ -571,6 +572,9 @@ public: {} // = default; explicit forward_list(const allocator_type& __a); explicit forward_list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit forward_list(size_type __n, const allocator_type& __a); +#endif forward_list(size_type __n, const value_type& __v); forward_list(size_type __n, const value_type& __v, const allocator_type& __a); template @@ -794,6 +798,28 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template +forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) + : base ( __a ) +{ + if (__n > 0) + { + __node_allocator& __a = base::__alloc(); + typedef __allocator_destructor<__node_allocator> _Dp; + unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); + for (__node_pointer __p = base::__before_begin(); __n > 0; --__n, + __p = __p->__next_) + { + __h.reset(__node_traits::allocate(__a, 1)); + __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); + __h->__next_ = nullptr; + __p->__next_ = __h.release(); + } + } +} +#endif + template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { diff --git a/contrib/libc++/include/fstream b/contrib/libc++/include/fstream index e3f8306f4..38778c677 100644 --- a/contrib/libc++/include/fstream +++ b/contrib/libc++/include/fstream @@ -180,7 +180,7 @@ typedef basic_fstream wfstream; _LIBCPP_BEGIN_NAMESPACE_STD template -class _LIBCPP_TYPE_VIS basic_filebuf +class _LIBCPP_TYPE_VIS_ONLY basic_filebuf : public basic_streambuf<_CharT, _Traits> { public: @@ -994,7 +994,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode() // basic_ifstream template -class _LIBCPP_TYPE_VIS basic_ifstream +class _LIBCPP_TYPE_VIS_ONLY basic_ifstream : public basic_istream<_CharT, _Traits> { public: @@ -1139,7 +1139,7 @@ basic_ifstream<_CharT, _Traits>::close() // basic_ofstream template -class _LIBCPP_TYPE_VIS basic_ofstream +class _LIBCPP_TYPE_VIS_ONLY basic_ofstream : public basic_ostream<_CharT, _Traits> { public: @@ -1284,7 +1284,7 @@ basic_ofstream<_CharT, _Traits>::close() // basic_fstream template -class _LIBCPP_TYPE_VIS basic_fstream +class _LIBCPP_TYPE_VIS_ONLY basic_fstream : public basic_iostream<_CharT, _Traits> { public: diff --git a/contrib/libc++/include/functional b/contrib/libc++/include/functional index d1a6301fb..d40f70af4 100644 --- a/contrib/libc++/include/functional +++ b/contrib/libc++/include/functional @@ -56,7 +56,7 @@ public: // invoke template - typename result_of::type + typename result_of::type operator() (ArgTypes&&...) const; }; @@ -68,96 +68,120 @@ template reference_wrapper cref(const T& t) noexcept; template void cref(const T&& t) = delete; template reference_wrapper cref(reference_wrapper t) noexcept; -template +template // in C++14 struct plus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct minus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct multiplies : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct divides : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct modulus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct negate : unary_function { T operator()(const T& x) const; }; -template +template // in C++14 struct equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct not_equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct greater : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct less : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct greater_equal : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct less_equal : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_and : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_or : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_not : unary_function { bool operator()(const T& x) const; }; +template // in C++14 +struct bit_and : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // in C++14 +struct bit_or : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // in C++14 +struct bit_xor : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // C++14 +struct bit_xor : unary_function +{ + bool operator()(const T& x) const; +}; + template class unary_negate : public unary_function @@ -334,18 +358,6 @@ template const_mem_fun_ref_t mem_fun_ref(S ( template const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); template unspecified mem_fn(R T::*); -template unspecified mem_fn(R (T::*)(Args...)); -template unspecified mem_fn(R (T::*)(Args...) const); -template unspecified mem_fn(R (T::*)(Args...) volatile); -template unspecified mem_fn(R (T::*)(Args...) const volatile); -template unspecified mem_fn(R (T::*)(Args...) &); -template unspecified mem_fn(R (T::*)(Args...) const &); -template unspecified mem_fn(R (T::*)(Args...) volatile &); -template unspecified mem_fn(R (T::*)(Args...) const volatile &); -template unspecified mem_fn(R (T::*)(Args...) &&); -template unspecified mem_fn(R (T::*)(Args...) const &&); -template unspecified mem_fn(R (T::*)(Args...) volatile &&); -template unspecified mem_fn(R (T::*)(Args...) const volatile &&); class bad_function_call : public exception @@ -473,166 +485,496 @@ POLICY: For non-variadic implementations, the number of arguments is limited _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS plus : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY plus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS minus : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY minus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY multiplies +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS divides : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY divides +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS modulus : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY modulus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS negate : unary_function<_Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const {return -__x;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY negate +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + { return -_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS equal_to : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY equal_to +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY not_equal_to +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS greater : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY greater +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + // less in <__functional_base> +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS greater_equal : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY greater_equal +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS less_equal : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY less_equal +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS logical_and : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY logical_and +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS logical_or : binary_function<_Tp, _Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY logical_or +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS logical_not : unary_function<_Tp, bool> +#endif +struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x) const {return !__x;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY logical_not +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + { return !_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY bit_and +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY bit_or +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template -struct _LIBCPP_TYPE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> +#endif +struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS_ONLY bit_xor +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> +{ + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const + {return ~__x;} +}; + +template <> +struct _LIBCPP_TYPE_VIS_ONLY bit_not +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + { return ~_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + template -class _LIBCPP_TYPE_VIS unary_negate +class _LIBCPP_TYPE_VIS_ONLY unary_negate : public unary_function { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + explicit unary_negate(const _Predicate& __pred) : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::argument_type& __x) const {return !__pred_(__x);} }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} template -class _LIBCPP_TYPE_VIS binary_negate +class _LIBCPP_TYPE_VIS_ONLY binary_negate : public binary_function { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred) - : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 + binary_negate(const _Predicate& __pred) : __pred_(__pred) {} + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {return !__pred_(__x, __y);} }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} template -class _LIBCPP_TYPE_VIS binder1st +class _LIBCPP_TYPE_VIS_ONLY binder1st : public unary_function { @@ -658,7 +1000,7 @@ bind1st(const __Operation& __op, const _Tp& __x) {return binder1st<__Operation>(__op, __x);} template -class _LIBCPP_TYPE_VIS binder2nd +class _LIBCPP_TYPE_VIS_ONLY binder2nd : public unary_function { @@ -684,7 +1026,7 @@ bind2nd(const __Operation& __op, const _Tp& __x) {return binder2nd<__Operation>(__op, __x);} template -class _LIBCPP_TYPE_VIS pointer_to_unary_function +class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function : public unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); @@ -702,7 +1044,7 @@ ptr_fun(_Result (*__f)(_Arg)) {return pointer_to_unary_function<_Arg,_Result>(__f);} template -class _LIBCPP_TYPE_VIS pointer_to_binary_function +class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); @@ -720,7 +1062,7 @@ ptr_fun(_Result (*__f)(_Arg1,_Arg2)) {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} template -class _LIBCPP_TYPE_VIS mem_fun_t : public unary_function<_Tp*, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -731,7 +1073,7 @@ public: }; template -class _LIBCPP_TYPE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -754,7 +1096,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TYPE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -765,7 +1107,7 @@ public: }; template -class _LIBCPP_TYPE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -788,7 +1130,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TYPE_VIS const_mem_fun_t : public unary_function +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function { _Sp (_Tp::*__p_)() const; public: @@ -799,7 +1141,7 @@ public: }; template -class _LIBCPP_TYPE_VIS const_mem_fun1_t : public binary_function +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function { _Sp (_Tp::*__p_)(_Ap) const; public: @@ -822,7 +1164,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TYPE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -833,7 +1175,7 @@ public: }; template -class _LIBCPP_TYPE_VIS const_mem_fun1_ref_t +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; @@ -893,38 +1235,6 @@ mem_fn(_Rp _Tp::* __pm) return __mem_fn<_Rp _Tp::*>(__pm); } -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...)> -mem_fn(_Rp (_Tp::* __pm)(_Args...)) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm); -} - // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -932,7 +1242,7 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call { }; -template class _LIBCPP_TYPE_VIS function; // undefined +template class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { @@ -1083,7 +1393,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT } // __function template -class _LIBCPP_TYPE_VIS function<_Rp(_ArgTypes...)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { @@ -1505,11 +1815,11 @@ swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCE {return __x.swap(__y);} template struct __is_bind_expression : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_bind_expression +template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression::type> {}; template struct __is_placeholder : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS is_placeholder +template struct _LIBCPP_TYPE_VIS_ONLY is_placeholder : public __is_placeholder::type> {}; namespace placeholders @@ -1517,16 +1827,16 @@ namespace placeholders template struct __ph {}; -extern __ph<1> _1; -extern __ph<2> _2; -extern __ph<3> _3; -extern __ph<4> _4; -extern __ph<5> _5; -extern __ph<6> _6; -extern __ph<7> _7; -extern __ph<8> _8; -extern __ph<9> _9; -extern __ph<10> _10; +_LIBCPP_FUNC_VIS extern __ph<1> _1; +_LIBCPP_FUNC_VIS extern __ph<2> _2; +_LIBCPP_FUNC_VIS extern __ph<3> _3; +_LIBCPP_FUNC_VIS extern __ph<4> _4; +_LIBCPP_FUNC_VIS extern __ph<5> _5; +_LIBCPP_FUNC_VIS extern __ph<6> _6; +_LIBCPP_FUNC_VIS extern __ph<7> _7; +_LIBCPP_FUNC_VIS extern __ph<8> _8; +_LIBCPP_FUNC_VIS extern __ph<9> _9; +_LIBCPP_FUNC_VIS extern __ph<10> _10; } // placeholders @@ -1888,7 +2198,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args) #endif // _LIBCPP_HAS_NO_VARIADICS template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1896,7 +2206,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1904,7 +2214,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1912,7 +2222,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1922,7 +2232,7 @@ struct _LIBCPP_TYPE_VIS hash #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1930,7 +2240,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1940,7 +2250,7 @@ struct _LIBCPP_TYPE_VIS hash #endif // _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1948,7 +2258,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1956,7 +2266,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1964,7 +2274,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1972,7 +2282,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1980,7 +2290,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1988,7 +2298,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -1996,19 +2306,19 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY @@ -2022,7 +2332,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY @@ -2036,7 +2346,7 @@ struct _LIBCPP_TYPE_VIS hash }; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY @@ -2085,6 +2395,22 @@ struct _LIBCPP_TYPE_VIS hash } }; +#if _LIBCPP_STD_VER > 11 +template +struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function<_Tp, size_t> +{ + static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); + + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + typedef typename underlying_type<_Tp>::type type; + return hash{}(static_cast(__v)); + } +}; +#endif + // struct hash in _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/future b/contrib/libc++/include/future index dae1a4b80..73d5456d7 100644 --- a/contrib/libc++/include/future +++ b/contrib/libc++/include/future @@ -19,10 +19,10 @@ namespace std enum class future_errc { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; enum class launch @@ -309,11 +309,11 @@ public: }; template - future::type> + future::type(typename decay::type...)>::type> async(F&& f, Args&&... args); template - future::type> + future::type(typename decay::type...)>::type> async(launch policy, F&& f, Args&&... args); template class packaged_task; // undefined @@ -379,19 +379,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc _LIBCPP_DECLARE_STRONG_ENUM(future_errc) { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum : public true_type {}; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type {}; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type { }; #endif //enum class launch @@ -508,7 +508,7 @@ public: virtual ~future_error() _NOEXCEPT; }; -class __assoc_sub_state +class _LIBCPP_TYPE_VIS __assoc_sub_state : public __shared_count { protected: @@ -542,14 +542,14 @@ public: __state_ |= __future_attached; } _LIBCPP_INLINE_VISIBILITY - bool __has_future_attached() const {return __state_ & __future_attached;} + bool __has_future_attached() const {return (__state_ & __future_attached) != 0;} _LIBCPP_INLINE_VISIBILITY void __set_deferred() {__state_ |= deferred;} void __make_ready(); _LIBCPP_INLINE_VISIBILITY - bool __is_ready() const {return __state_ & ready;} + bool __is_ready() const {return (__state_ & ready) != 0;} void set_value(); void set_value_at_thread_exit(); @@ -727,7 +727,7 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg) if (this->__has_value()) throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif - __value_ = &__arg; + __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __lk.unlock(); __cv_.notify_all(); @@ -742,7 +742,7 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) if (this->__has_value()) throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif - __value_ = &__arg; + __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); __lk.unlock(); @@ -778,7 +778,7 @@ void __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) - reinterpret_cast<_Rp*>(&this->__value_)->~_Rp(); + reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(this, 1); @@ -1032,12 +1032,12 @@ __async_assoc_state::__on_zero_shared() _NOEXCEPT base::__on_zero_shared(); } -template class _LIBCPP_TYPE_VIS promise; -template class _LIBCPP_TYPE_VIS shared_future; +template class _LIBCPP_TYPE_VIS_ONLY promise; +template class _LIBCPP_TYPE_VIS_ONLY shared_future; // future -template class _LIBCPP_TYPE_VIS future; +template class _LIBCPP_TYPE_VIS_ONLY future; template future<_Rp> @@ -1056,7 +1056,7 @@ __make_async_assoc_state(_Fp __f); #endif template -class _LIBCPP_TYPE_VIS future +class _LIBCPP_TYPE_VIS_ONLY future { __assoc_state<_Rp>* __state_; @@ -1160,7 +1160,7 @@ future<_Rp>::get() } template -class _LIBCPP_TYPE_VIS future<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY future<_Rp&> { __assoc_state<_Rp&>* __state_; @@ -1341,7 +1341,7 @@ swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT template class packaged_task; template -class _LIBCPP_TYPE_VIS promise +class _LIBCPP_TYPE_VIS_ONLY promise { __assoc_state<_Rp>* __state_; @@ -1519,7 +1519,7 @@ promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) // promise template -class _LIBCPP_TYPE_VIS promise<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY promise<_Rp&> { __assoc_state<_Rp&>* __state_; @@ -1736,7 +1736,7 @@ swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT } template - struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> + struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : public true_type {}; #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2000,7 +2000,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) cons } template -class _LIBCPP_TYPE_VIS packaged_task<_Rp(_ArgTypes...)> +class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)> { public: typedef _Rp result_type; @@ -2013,10 +2013,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2115,7 +2131,7 @@ packaged_task<_Rp(_ArgTypes...)>::reset() } template -class _LIBCPP_TYPE_VIS packaged_task +class _LIBCPP_TYPE_VIS_ONLY packaged_task { public: typedef void result_type; @@ -2128,10 +2144,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2240,7 +2272,7 @@ swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT } template -struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : public true_type {}; template @@ -2299,20 +2331,32 @@ private: } }; +inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value ) +{ return (int(__policy) & int(__value)) != 0; } + template future::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; - future<_Rp> __r; - if (int(__policy) & int(launch::async)) - __r = _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), + +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif + if (__does_policy_contain(__policy, launch::async)) + return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - else if (int(__policy) & int(launch::deferred)) - __r = _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch ( ... ) { if (__policy == launch::async) throw ; } +#endif + + if (__does_policy_contain(__policy, launch::deferred)) + return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - return __r; + return future<_Rp>{}; } template @@ -2329,7 +2373,7 @@ async(_Fp&& __f, _Args&&... __args) // shared_future template -class _LIBCPP_TYPE_VIS shared_future +class _LIBCPP_TYPE_VIS_ONLY shared_future { __assoc_state<_Rp>* __state_; @@ -2403,7 +2447,7 @@ shared_future<_Rp>::operator=(const shared_future& __rhs) } template -class _LIBCPP_TYPE_VIS shared_future<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY shared_future<_Rp&> { __assoc_state<_Rp&>* __state_; diff --git a/contrib/libc++/include/initializer_list b/contrib/libc++/include/initializer_list index 181313d17..663e49b6e 100644 --- a/contrib/libc++/include/initializer_list +++ b/contrib/libc++/include/initializer_list @@ -29,15 +29,15 @@ public: typedef const E* iterator; typedef const E* const_iterator; - initializer_list() noexcept; + initializer_list() noexcept; // constexpr in C++14 - size_t size() const noexcept; - const E* begin() const noexcept; - const E* end() const noexcept; + size_t size() const noexcept; // constexpr in C++14 + const E* begin() const noexcept; // constexpr in C++14 + const E* end() const noexcept; // constexpr in C++14 }; -template const E* begin(initializer_list il) noexcept; -template const E* end(initializer_list il) noexcept; +template const E* begin(initializer_list il) noexcept; // constexpr in C++14 +template const E* end(initializer_list il) noexcept; // constexpr in C++14 } // std @@ -56,12 +56,13 @@ namespace std // purposefully not versioned #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -class _LIBCPP_TYPE_VIS initializer_list +class _LIBCPP_TYPE_VIS_ONLY initializer_list { const _Ep* __begin_; size_t __size_; _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT : __begin_(__b), __size_(__s) @@ -75,15 +76,26 @@ public: typedef const _Ep* iterator; typedef const _Ep* const_iterator; - _LIBCPP_ALWAYS_INLINE initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} - _LIBCPP_ALWAYS_INLINE size_t size() const _NOEXCEPT {return __size_;} - _LIBCPP_ALWAYS_INLINE const _Ep* begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_ALWAYS_INLINE const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + size_t size() const _NOEXCEPT {return __size_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* begin() const _NOEXCEPT {return __begin_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} }; template inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT { @@ -92,6 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT template inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT { diff --git a/contrib/libc++/include/iomanip b/contrib/libc++/include/iomanip index 0c58e1980..e334c7de9 100644 --- a/contrib/libc++/include/iomanip +++ b/contrib/libc++/include/iomanip @@ -14,6 +14,8 @@ /* iomanip synopsis +namespace std { + // types T1, T2, ... are unspecified implementation types T1 resetiosflags(ios_base::fmtflags mask); T2 setiosflags (ios_base::fmtflags mask); @@ -26,6 +28,17 @@ template T8 put_money(const moneyT& mon, bool intl = template T9 get_time(struct tm* tmb, const charT* fmt); template T10 put_time(const struct tm* tmb, const charT* fmt); +template + T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template + T12 quoted(const basic_string& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template + T13 quoted(basic_string& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + } // std */ @@ -499,6 +512,142 @@ put_time(const tm* __tm, const _CharT* __fmt) return __iom_t10<_CharT>(__tm, __fmt); } +#if _LIBCPP_STD_VER > 11 + +template +std::basic_ostream<_CharT, _Traits> & +__quoted_output ( basic_ostream<_CharT, _Traits> &__os, + _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) +{ + __os << __delim; + for ( ; __first != __last; ++ __first ) + { + if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) + __os << __escape; + __os << *__first; + } + __os << __delim; + return __os; +} + +template +basic_istream<_CharT, _Traits> & +__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) +{ + __string.clear (); + _CharT __c; + __is >> __c; + if ( __is.fail ()) + return __is; + + if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string + { + __is.unget (); + __is >> __string; + return __is; + } + + __save_flags<_CharT, _Traits> sf(__is); + noskipws (__is); + while (true) + { + __is >> __c; + if ( __is.fail ()) + break; + if (_Traits::eq (__c, __escape)) + { + __is >> __c; + if ( __is.fail ()) + break; + } + else if (_Traits::eq (__c, __delim)) + break; + __string.push_back ( __c ); + } + return __is; +} + + +template > +struct __quoted_output_proxy +{ + _Iter __first; + _Iter __last; + _CharT __delim; + _CharT __escape; + + __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) + : __first(__f), __last(__l), __delim(__d), __escape(__e) {} + // This would be a nice place for a string_ref +}; + +template +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) +{ + return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); +} + +template +struct __quoted_proxy +{ + basic_string<_CharT, _Traits, _Allocator> &__string; + _CharT __delim; + _CharT __escape; + + __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) + : __string(__s), __delim(__d), __escape(__e) {} +}; + +template +_LIBCPP_INLINE_VISIBILITY +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape); +} + +// extractor for non-const basic_string& proxies +template +_LIBCPP_INLINE_VISIBILITY +basic_istream<_CharT, _Traits>& operator>>( + basic_istream<_CharT, _Traits>& __is, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); +} + + +template +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, const _CharT *> +quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) +{ + const _CharT *__end = __s; + while ( *__end ) ++__end; + return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); +} + +template +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> +quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_output_proxy<_CharT, + typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> + ( __s.cbegin(), __s.cend (), __delim, __escape ); +} + +template +__quoted_proxy<_CharT, _Traits, _Allocator> +quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOMANIP diff --git a/contrib/libc++/include/ios b/contrib/libc++/include/ios index 25bbfc0b6..d95f18a5e 100644 --- a/contrib/libc++/include/ios +++ b/contrib/libc++/include/ios @@ -203,9 +203,9 @@ enum class io_errc }; concept_map ErrorCodeEnum { }; -error_code make_error_code(io_errc e); -error_condition make_error_condition(io_errc e); -storage-class-specifier const error_category& iostream_category; +error_code make_error_code(io_errc e) noexcept; +error_condition make_error_condition(io_errc e) noexcept; +storage-class-specifier const error_category& iostream_category() noexcept; } // std @@ -216,6 +216,10 @@ storage-class-specifier const error_category& iostream_category; #include <__locale> #include +#if __has_feature(cxx_atomic) +#include // for __xindex_ +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -319,7 +323,7 @@ public: _LIBCPP_INLINE_VISIBILITY bool bad() const; _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; - _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except); + _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); void __set_badbit_and_consider_rethrow(); void __set_failbit_and_consider_rethrow(); @@ -363,7 +367,11 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; +#if __has_feature(cxx_atomic) + static atomic __xindex_; +#else static int __xindex_; +#endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; @@ -380,26 +388,26 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type { }; #endif _LIBCPP_FUNC_VIS -const error_category& iostream_category(); +const error_category& iostream_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code -make_error_code(io_errc __e) +make_error_code(io_errc __e) _NOEXCEPT { return error_code(static_cast(__e), iostream_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition -make_error_condition(io_errc __e) +make_error_condition(io_errc __e) _NOEXCEPT { return error_condition(static_cast(__e), iostream_category()); } @@ -527,21 +535,21 @@ inline _LIBCPP_INLINE_VISIBILITY bool ios_base::eof() const { - return __rdstate_ & eofbit; + return (__rdstate_ & eofbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::fail() const { - return __rdstate_ & (failbit | badbit); + return (__rdstate_ & (failbit | badbit)) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::bad() const { - return __rdstate_ & badbit; + return (__rdstate_ & badbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY @@ -553,14 +561,14 @@ ios_base::exceptions() const inline _LIBCPP_INLINE_VISIBILITY void -ios_base::exceptions(iostate __except) +ios_base::exceptions(iostate __iostate) { - __exceptions_ = __except; + __exceptions_ = __iostate; clear(__rdstate_); } template -class _LIBCPP_TYPE_VIS basic_ios +class _LIBCPP_TYPE_VIS_ONLY basic_ios : public ios_base { public: @@ -585,7 +593,7 @@ public: _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} - _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} + _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} // 27.5.4.1 Constructor/destructor: _LIBCPP_INLINE_VISIBILITY @@ -983,6 +991,33 @@ defaultfloat(ios_base& __str) return __str; } +template +class __save_flags +{ + typedef basic_ios<_CharT, _Traits> __stream_type; + typedef typename __stream_type::fmtflags fmtflags; + + __stream_type& __stream_; + fmtflags __fmtflags_; + _CharT __fill_; + + __save_flags(const __save_flags&); + __save_flags& operator=(const __save_flags&); +public: + _LIBCPP_INLINE_VISIBILITY + explicit __save_flags(__stream_type& __stream) + : __stream_(__stream), + __fmtflags_(__stream.flags()), + __fill_(__stream.fill()) + {} + _LIBCPP_INLINE_VISIBILITY + ~__save_flags() + { + __stream_.flags(__fmtflags_); + __stream_.fill(__fill_); + } +}; + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOS diff --git a/contrib/libc++/include/iosfwd b/contrib/libc++/include/iosfwd index 849d7e517..d24c227be 100644 --- a/contrib/libc++/include/iosfwd +++ b/contrib/libc++/include/iosfwd @@ -97,47 +97,47 @@ _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS ios_base; -template struct _LIBCPP_TYPE_VIS char_traits; -template class _LIBCPP_TYPE_VIS allocator; +template struct _LIBCPP_TYPE_VIS_ONLY char_traits; +template class _LIBCPP_TYPE_VIS_ONLY allocator; template > - class _LIBCPP_TYPE_VIS basic_ios; + class _LIBCPP_TYPE_VIS_ONLY basic_ios; template > - class _LIBCPP_TYPE_VIS basic_streambuf; + class _LIBCPP_TYPE_VIS_ONLY basic_streambuf; template > - class _LIBCPP_TYPE_VIS basic_istream; + class _LIBCPP_TYPE_VIS_ONLY basic_istream; template > - class _LIBCPP_TYPE_VIS basic_ostream; + class _LIBCPP_TYPE_VIS_ONLY basic_ostream; template > - class _LIBCPP_TYPE_VIS basic_iostream; + class _LIBCPP_TYPE_VIS_ONLY basic_iostream; template , class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_stringbuf; + class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf; template , class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_istringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_istringstream; template , class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_ostringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream; template , class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_stringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_stringstream; template > - class _LIBCPP_TYPE_VIS basic_filebuf; + class _LIBCPP_TYPE_VIS_ONLY basic_filebuf; template > - class _LIBCPP_TYPE_VIS basic_ifstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ifstream; template > - class _LIBCPP_TYPE_VIS basic_ofstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ofstream; template > - class _LIBCPP_TYPE_VIS basic_fstream; + class _LIBCPP_TYPE_VIS_ONLY basic_fstream; template > - class _LIBCPP_TYPE_VIS istreambuf_iterator; + class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator; template > - class _LIBCPP_TYPE_VIS ostreambuf_iterator; + class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator; typedef basic_ios ios; typedef basic_ios wios; @@ -172,7 +172,7 @@ typedef basic_ifstream wifstream; typedef basic_ofstream wofstream; typedef basic_fstream wfstream; -template class _LIBCPP_TYPE_VIS fpos; +template class _LIBCPP_TYPE_VIS_ONLY fpos; typedef fpos streampos; typedef fpos wstreampos; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -185,7 +185,7 @@ typedef long long streamoff; // for char_traits in template class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_string; + class _LIBCPP_TYPE_VIS_ONLY basic_string; typedef basic_string, allocator > string; typedef basic_string, allocator > wstring; diff --git a/contrib/libc++/include/istream b/contrib/libc++/include/istream index f3e74c382..14fa46605 100644 --- a/contrib/libc++/include/istream +++ b/contrib/libc++/include/istream @@ -164,7 +164,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD template -class _LIBCPP_TYPE_VIS basic_istream +class _LIBCPP_TYPE_VIS_ONLY basic_istream : virtual public basic_ios<_CharT, _Traits> { streamsize __gc_; @@ -194,7 +194,7 @@ protected: public: // 27.7.1.1.3 Prefix/suffix: - class _LIBCPP_TYPE_VIS sentry; + class _LIBCPP_TYPE_VIS_ONLY sentry; // 27.7.1.2 Formatted input: basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); @@ -244,7 +244,7 @@ public: }; template -class _LIBCPP_TYPE_VIS basic_istream<_CharT, _Traits>::sentry +class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry { bool __ok_; @@ -1369,8 +1369,10 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos) this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) + { if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -1391,7 +1393,10 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) + this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -1451,7 +1456,7 @@ operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -class _LIBCPP_TYPE_VIS basic_iostream +class _LIBCPP_TYPE_VIS_ONLY basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { @@ -1702,9 +1707,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) return __is; } -_LIBCPP_EXTERN_TEMPLATE(class basic_istream) -_LIBCPP_EXTERN_TEMPLATE(class basic_istream) -_LIBCPP_EXTERN_TEMPLATE(class basic_iostream) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/iterator b/contrib/libc++/include/iterator index dda053da3..70a664d99 100644 --- a/contrib/libc++/include/iterator +++ b/contrib/libc++/include/iterator @@ -309,6 +309,19 @@ template auto end(const C& c) -> decltype(c.end()); template T* begin(T (&array)[N]); template T* end(T (&array)[N]); +template auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template auto rend(C& c) -> decltype(c.rend()); // C++14 +template auto rend(const C& c) -> decltype(c.rend()); // C++14 +template reverse_iterator rbegin(initializer_list il); // C++14 +template reverse_iterator rend(initializer_list il); // C++14 +template reverse_iterator rbegin(T (&array)[N]); // C++14 +template reverse_iterator rend(T (&array)[N]); // C++14 +template auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template auto crend(const C& c) -> decltype(std::rend(c)); // C++14 + } // std */ @@ -317,12 +330,15 @@ template T* end(T (&array)[N]); #include #include #include +#include #ifdef __APPLE__ #include #endif #ifdef _LIBCPP_DEBUG -#include +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -331,11 +347,11 @@ template T* end(T (&array)[N]); _LIBCPP_BEGIN_NAMESPACE_STD -struct _LIBCPP_TYPE_VIS input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS output_iterator_tag {}; -struct _LIBCPP_TYPE_VIS forward_iterator_tag : public input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; -struct _LIBCPP_TYPE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY output_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY forward_iterator_tag : public input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY bidirectional_iterator_tag : public forward_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY random_access_iterator_tag : public bidirectional_iterator_tag {}; template struct __has_iterator_category @@ -378,11 +394,11 @@ struct __iterator_traits<_Iter, true> // the client expects instead of failing at compile time. template -struct _LIBCPP_TYPE_VIS iterator_traits +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits : __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {}; template -struct _LIBCPP_TYPE_VIS iterator_traits<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits<_Tp*> { typedef ptrdiff_t difference_type; typedef typename remove_const<_Tp>::type value_type; @@ -413,7 +429,7 @@ struct __is_random_access_iterator : public __has_iterator_category_convertible_ template -struct _LIBCPP_TYPE_VIS iterator +struct _LIBCPP_TYPE_VIS_ONLY iterator { typedef _Tp value_type; typedef _Distance difference_type; @@ -510,7 +526,7 @@ prev(_BidiretionalIter __x, } template -class _LIBCPP_TYPE_VIS reverse_iterator +class _LIBCPP_TYPE_VIS_ONLY reverse_iterator : public iterator::iterator_category, typename iterator_traits<_Iter>::value_type, typename iterator_traits<_Iter>::difference_type, @@ -617,7 +633,7 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i } template -class _LIBCPP_TYPE_VIS back_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator : public iterator -class _LIBCPP_TYPE_VIS front_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY front_insert_iterator : public iterator -class _LIBCPP_TYPE_VIS insert_iterator +class _LIBCPP_TYPE_VIS_ONLY insert_iterator : public iterator, class _Distance = ptrdiff_t> -class _LIBCPP_TYPE_VIS istream_iterator +class _LIBCPP_TYPE_VIS_ONLY istream_iterator : public iterator { public: @@ -758,7 +774,7 @@ public: }; template > -class _LIBCPP_TYPE_VIS ostream_iterator +class _LIBCPP_TYPE_VIS_ONLY ostream_iterator : public iterator { public: @@ -787,7 +803,7 @@ public: }; template -class _LIBCPP_TYPE_VIS istreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator : public iterator @@ -858,7 +874,7 @@ bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, {return !__a.equal(__b);} template -class _LIBCPP_TYPE_VIS ostreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator : public iterator { public: @@ -899,7 +915,7 @@ public: }; template -class _LIBCPP_TYPE_VIS move_iterator +class _LIBCPP_TYPE_VIS_ONLY move_iterator { private: _Iter __i; @@ -1014,7 +1030,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato template inline _LIBCPP_INLINE_VISIBILITY move_iterator<_Iter> -make_move_iterator(const _Iter& __i) +make_move_iterator(_Iter __i) { return move_iterator<_Iter>(__i); } @@ -1091,6 +1107,9 @@ private: iterator_type __i; public: _LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __i{} +#endif { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); @@ -1192,12 +1211,13 @@ public: _LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT {return __i;} private: - _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x) { __get_db()->__insert_ic(this, __p); } +#else + _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #endif template friend class __wrap_iter; @@ -1264,10 +1284,6 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__comparable(&__x, &__y), - "Attempted to compare incomparable iterators"); -#endif return __x.base() == __y.base(); } @@ -1277,7 +1293,7 @@ bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__comparable(&__x, &__y), + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), "Attempted to compare incomparable iterators"); #endif return __x.base() < __y.base(); @@ -1353,7 +1369,7 @@ typename __wrap_iter<_Iter1>::difference_type operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__comparable(&__x, &__y), + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), "Attempted to subtract incompatible iterators"); #endif return __x.base() - __y.base(); @@ -1369,456 +1385,145 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } -#ifdef _LIBCPP_DEBUG - -// __debug_iter - -template class __debug_iter; - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template -_LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&); - -template -class __debug_iter -{ -public: - typedef _Iter iterator_type; - typedef _Container __container_type; - typedef typename iterator_traits::iterator_category iterator_category; - typedef typename iterator_traits::value_type value_type; - typedef typename iterator_traits::difference_type difference_type; - typedef typename iterator_traits::pointer pointer; - typedef typename iterator_traits::reference reference; -private: - iterator_type __i; - __debug_iter* __next; - __container_type* __cont; - -public: - _LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {} - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x) - : __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);} - __debug_iter& operator=(const __debug_iter& __x); - template _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u, - typename enable_if::value>::type* = 0) - : __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);} - _LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int) - {__debug_iter __tmp(*this); operator++(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int) - {__debug_iter __tmp(*this); operator--(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const - {__debug_iter __t(*this); __t += __n; return __t;} - __debug_iter& operator+=(difference_type __n); - _LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const - {__debug_iter __t(*this); __t -= __n; return __t;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n) - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return *(*this + __n);} - -private: - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x) - : __i(__x), __next(0), __cont(0) {__set_owner(__c);} - _LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;} - - void __set_owner(const __container_type* __c); - void __remove_owner(); - static void __remove_all(__container_type* __c); - static void swap(__container_type* __x, __container_type* __y); - - _LIBCPP_INLINE_VISIBILITY bool __is_deref() const - {return __is_deref(__is_random_access_iterator());} - bool __is_deref(false_type) const; - bool __is_deref(true_type) const; - _LIBCPP_INLINE_VISIBILITY bool __can_decrement() const - {return __can_decrement(integral_constant::value ? 2: - __is_random_access_iterator::value ? 1 : 0>());} - bool __can_decrement(integral_constant) const; - bool __can_decrement(integral_constant) const; - bool __can_decrement(integral_constant) const; - _LIBCPP_INLINE_VISIBILITY bool __can_increment() const - {return __can_increment(integral_constant::value ? 2: - __is_random_access_iterator::value ? 1 : 0>());} - bool __can_increment(integral_constant) const; - bool __can_increment(integral_constant) const; - bool __can_increment(integral_constant) const; - - _LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const - {return __can_add(__n, is_pointer());} - bool __can_add(difference_type __n, false_type) const; - bool __can_add(difference_type __n, true_type) const; - - template friend class __debug_iter; - friend class _Container::__self; - - template - friend - bool - operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - bool - operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - bool - operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - bool - operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - bool - operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - bool - operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - typename __debug_iter<_Cp, _Iter1>::difference_type - operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template - friend - __debug_iter<_Cp, _Iter1> - operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&); -}; - -template -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x) -{ - if (this != &__x) - { - __remove_owner(); - __i = __x.__i; - __set_owner(__x.__cont); - } - return *this; -} - -template -void -__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c) -{ - __cont = const_cast<__container_type*>(__c); - __debug_iter*& __head = __cont->__get_iterator_list(this); - __next = __head; - __head = this; -} - -template -void -__debug_iter<_Container, _Iter>::__remove_owner() -{ - if (__cont) - { - __debug_iter*& __head = __cont->__get_iterator_list(this); - if (__head == this) - __head = __next; - else - { - __debug_iter* __prev = __head; - for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next) - __prev = __p; - __prev->__next = __next; - } - __cont = 0; - } -} - -template -void -__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c) -{ - __debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head; - __head = 0; - while (__p) - { - __p->__cont = 0; - __debug_iter* __n = __p->__next; - __p->__next = 0; - __p = __n; - } -} - -template -void -__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y) -{ - __debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0); - __debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head_x; - __head_x = __head_y; - __head_y = __p; - for (__p = __head_x; __p; __p = __p->__next) - __p->__cont = __x; - for (__p = __head_y; __p; __p = __p->__next) - __p->__cont = __y; -} - -template -bool -__debug_iter<_Container, _Iter>::__is_deref(false_type) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template -bool -__debug_iter<_Container, _Iter>::__is_deref(true_type) const -{ - if (__cont == 0) - return false; - return __i < __cont->end().base(); -} - -template -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant) const -{ - if (__cont == 0) - return false; - return __i != __cont->begin().base(); -} - -template -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant) const +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +begin(_Tp (&__array)[_Np]) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); + return __array; } -template -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant) const +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +end(_Tp (&__array)[_Np]) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); + return __array + _Np; } -template -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant) const +template +inline _LIBCPP_INLINE_VISIBILITY +auto +begin(_Cp& __c) -> decltype(__c.begin()) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); + return __c.begin(); } -template -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant) const +template +inline _LIBCPP_INLINE_VISIBILITY +auto +begin(const _Cp& __c) -> decltype(__c.begin()) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); + return __c.begin(); } -template -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const +template +inline _LIBCPP_INLINE_VISIBILITY +auto +end(_Cp& __c) -> decltype(__c.end()) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); + return __c.end(); } -template -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const +template +inline _LIBCPP_INLINE_VISIBILITY +auto +end(const _Cp& __c) -> decltype(__c.end()) { - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); + return __c.end(); } -template -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator+=(difference_type __n) -{ - assert(__can_add(__n)); - __i += __n; - return *this; -} +#if _LIBCPP_STD_VER > 11 -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() == __y.base(); + return reverse_iterator<_Tp*>(__array + _Np); } -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) { - return !(__x == __y); + return reverse_iterator<_Tp*>(__array); } -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +reverse_iterator rbegin(initializer_list<_Ep> __il) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() < __y.base(); + return reverse_iterator(__il.end()); } -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +reverse_iterator rend(initializer_list<_Ep> __il) { - return __y < __x; + return reverse_iterator(__il.begin()); } -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cbegin(const _Cp& __c) -> decltype(begin(__c)) { - return !(__x < __y); + return _VSTD::begin(__c); } -template +template inline _LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cend(const _Cp& __c) -> decltype(end(__c)) { - return !(__y < __x); + return _VSTD::end(__c); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() - __y.base(); + return __c.rbegin(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, - const __debug_iter<_Container, _Iter>& __x) +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { - return __x + __n; + return __c.rbegin(); } -#endif // _LIBCPP_DEBUG - -#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) - template inline _LIBCPP_INLINE_VISIBILITY -auto -begin(_Cp& __c) -> decltype(__c.begin()) +auto rend(_Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template inline _LIBCPP_INLINE_VISIBILITY -auto -begin(const _Cp& __c) -> decltype(__c.begin()) +auto rend(const _Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template inline _LIBCPP_INLINE_VISIBILITY -auto -end(_Cp& __c) -> decltype(__c.end()) +auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) { - return __c.end(); + return rbegin(__c); } template inline _LIBCPP_INLINE_VISIBILITY -auto -end(const _Cp& __c) -> decltype(__c.end()) +auto crend(const _Cp& __c) -> decltype(rend(__c)) { - return __c.end(); + return rend(__c); } +#endif + + #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template @@ -1855,22 +1560,6 @@ end(const _Cp& __c) #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -begin(_Tp (&__array)[_Np]) -{ - return __array; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -end(_Tp (&__array)[_Np]) -{ - return __array + _Np; -} - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ITERATOR diff --git a/contrib/libc++/include/limits b/contrib/libc++/include/limits index 9b9d7a6f8..d917c577f 100644 --- a/contrib/libc++/include/limits +++ b/contrib/libc++/include/limits @@ -111,9 +111,13 @@ template<> class numeric_limits; #include <__undef_min_max> -#if defined(_MSC_VER) +#if defined(_LIBCPP_MSVCRT) #include "support/win32/limits_win32.h" -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT + +#if defined(__IBMCPP__) +#include "support/ibm/limits.h" +#endif // __IBMCPP__ _LIBCPP_BEGIN_NAMESPACE_STD @@ -433,7 +437,7 @@ protected: }; template -class _LIBCPP_TYPE_VIS numeric_limits +class _LIBCPP_TYPE_VIS_ONLY numeric_limits : private __libcpp_numeric_limits::type> { typedef __libcpp_numeric_limits::type> __base; @@ -526,7 +530,7 @@ template _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; template -class _LIBCPP_TYPE_VIS numeric_limits +class _LIBCPP_TYPE_VIS_ONLY numeric_limits : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; @@ -619,7 +623,7 @@ template _LIBCPP_CONSTEXPR const float_round_style numeric_limits::round_style; template -class _LIBCPP_TYPE_VIS numeric_limits +class _LIBCPP_TYPE_VIS_ONLY numeric_limits : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; @@ -712,7 +716,7 @@ template _LIBCPP_CONSTEXPR const float_round_style numeric_limits::round_style; template -class _LIBCPP_TYPE_VIS numeric_limits +class _LIBCPP_TYPE_VIS_ONLY numeric_limits : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; diff --git a/contrib/libc++/include/list b/contrib/libc++/include/list index 628a35bad..800a1a3f5 100644 --- a/contrib/libc++/include/list +++ b/contrib/libc++/include/list @@ -40,6 +40,7 @@ public: noexcept(is_nothrow_default_constructible::value); explicit list(const allocator_type& a); explicit list(size_type n); + explicit list(size_type n, const allocator_type& a); // C++14 list(size_type n, const value_type& value); list(size_type n, const value_type& value, const allocator_type& a); template @@ -178,6 +179,12 @@ template #include <__undef_min_max> +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -220,12 +227,12 @@ struct __list_node _Tp __value_; }; -template class _LIBCPP_TYPE_VIS list; +template class _LIBCPP_TYPE_VIS_ONLY list; template class __list_imp; -template class _LIBCPP_TYPE_VIS __list_const_iterator; +template class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator; template -class _LIBCPP_TYPE_VIS __list_iterator +class _LIBCPP_TYPE_VIS_ONLY __list_iterator { typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -267,7 +274,7 @@ public: typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY - __list_iterator() _NOEXCEPT + __list_iterator() _NOEXCEPT : __ptr_(nullptr) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); @@ -350,10 +357,6 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __list_iterator& __x, const __list_iterator& __y) { -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__comparable(&__x, &__y), - "Attempted to compare non-comparable list::iterator"); -#endif return __x.__ptr_ == __y.__ptr_; } friend _LIBCPP_INLINE_VISIBILITY @@ -362,7 +365,7 @@ public: }; template -class _LIBCPP_TYPE_VIS __list_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator { typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -401,7 +404,7 @@ public: typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY - __list_const_iterator() _NOEXCEPT + __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); @@ -491,10 +494,6 @@ public: friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) { -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__comparable(&__x, &__y), - "Attempted to compare non-comparable list::const_iterator"); -#endif return __x.__ptr_ == __y.__ptr_; } friend _LIBCPP_INLINE_VISIBILITY @@ -808,7 +807,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) } template > -class _LIBCPP_TYPE_VIS list +class _LIBCPP_TYPE_VIS_ONLY list : private __list_imp<_Tp, _Alloc> { typedef __list_imp<_Tp, _Alloc> base; @@ -844,13 +843,16 @@ public: #endif } _LIBCPP_INLINE_VISIBILITY - list(const allocator_type& __a) : base(__a) + explicit list(const allocator_type& __a) : base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } - list(size_type __n); + explicit list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit list(size_type __n, const allocator_type& __a); +#endif list(size_type __n, const value_type& __x); list(size_type __n, const value_type& __x, const allocator_type& __a); template @@ -1102,6 +1104,22 @@ list<_Tp, _Alloc>::list(size_type __n) #endif } +#if _LIBCPP_STD_VER > 11 +template +list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + for (; __n > 0; --__n) +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + emplace_back(); +#else + push_back(value_type()); +#endif +} +#endif + template list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale index ef7603d03..cdfe120e7 100644 --- a/contrib/libc++/include/locale +++ b/contrib/libc++/include/locale @@ -93,10 +93,12 @@ public: typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - wstring_convert(Codecvt* pcvt = new Codecvt); + explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 wstring_convert(Codecvt* pcvt, state_type state); - wstring_convert(const byte_string& byte_err, + explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); + wstring_convert(const wstring_convert&) = delete; // C++14 + wstring_convert & operator=(const wstring_convert &) = delete; // C++14 ~wstring_convert(); wide_string from_bytes(char byte); @@ -109,7 +111,7 @@ public: byte_string to_bytes(const wide_string& wstr); byte_string to_bytes(const Elem* first, const Elem* last); - size_t converted() const; + size_t converted() const; // noexcept in C++14 state_type state() const; }; @@ -120,9 +122,12 @@ class wbuffer_convert public: typedef typename Tr::state_type state_type; - wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, - state_type state = state_type()); - + explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // explicit in C++14 + wbuffer_convert(const wbuffer_convert&) = delete; // C++14 + wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 + ~wbuffer_convert(); // C++14 + streambuf* rdbuf() const; streambuf* rdbuf(streambuf* bytebuf); @@ -186,11 +191,11 @@ template class messages_byname; #endif #include #include -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include -#else // _WIN32 +#else // _LIBCPP_MSVCRT #include -#endif // !_WIN32 +#endif // !_LIBCPP_MSVCRT #ifdef __APPLE__ #include @@ -211,7 +216,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #else # define _LIBCPP_GET_C_LOCALE __cloc() // Get the C locale object - locale_t __cloc(); + _LIBCPP_FUNC_VIS locale_t __cloc(); #define __cloc_defined #endif @@ -224,7 +229,7 @@ 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) +#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) #ifdef _LIBCPP_LOCALE__L_EXTENSIONS decltype(MB_CUR_MAX_L(_VSTD::declval())) @@ -234,7 +239,7 @@ __mb_cur_max_l(locale_t __l) return MB_CUR_MAX_L(__l); } #else // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) { __locale_raii __current(uselocale(__l), uselocale); @@ -242,7 +247,7 @@ decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) } #endif // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE wint_t __btowc_l(int __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -253,7 +258,7 @@ wint_t __btowc_l(int __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __wctob_l(wint_t __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -264,7 +269,7 @@ int __wctob_l(wint_t __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -276,7 +281,7 @@ size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -287,7 +292,7 @@ size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -299,7 +304,7 @@ size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { @@ -311,7 +316,7 @@ size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -322,7 +327,7 @@ int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -333,7 +338,7 @@ size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE lconv *__localeconv_l(locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -344,7 +349,7 @@ lconv *__localeconv_l(locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -528,7 +533,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, return __kb; } -struct __num_get_base +struct _LIBCPP_TYPE_VIS __num_get_base { static const int __num_get_buf_sz = 40; @@ -536,6 +541,7 @@ struct __num_get_base static const char __src[33]; }; +_LIBCPP_FUNC_VIS void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err); @@ -686,11 +692,11 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex return 0; } -_LIBCPP_EXTERN_TEMPLATE(struct __num_get) -_LIBCPP_EXTERN_TEMPLATE(struct __num_get) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get) template > -class _LIBCPP_TYPE_VIS num_get +class _LIBCPP_TYPE_VIS_ONLY num_get : public locale::facet, private __num_get<_CharT> { @@ -785,26 +791,61 @@ protected: _LIBCPP_ALWAYS_INLINE ~num_get() {} + template + iter_type __do_get_floating_point + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Fp& __v) const; + + template + iter_type __do_get_signed + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Signed& __v) const; + + template + iter_type __do_get_unsigned + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Unsigned& __v) const; + + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long& __v) const; + ios_base::iostate& __err, long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long long& __v) const; + ios_base::iostate& __err, long long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned short& __v) const; + ios_base::iostate& __err, unsigned short& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned int& __v) const; + ios_base::iostate& __err, unsigned int& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long& __v) const; + ios_base::iostate& __err, unsigned long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long long& __v) const; + ios_base::iostate& __err, unsigned long long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, float& __v) const; + ios_base::iostate& __err, float& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, double& __v) const; + ios_base::iostate& __err, double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long double& __v) const; + ios_base::iostate& __err, long double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; }; @@ -946,153 +987,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned short& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// signed template +template _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned int& __v) const + _Signed& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1109,7 +1012,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, unsigned __dc = 0; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1125,7 +1028,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral(__a, __a_end, __err, __base); + __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1134,59 +1037,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// unsigned template +template _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned long long& __v) const + _Unsigned& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1203,7 +1062,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, unsigned __dc = 0; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1219,59 +1078,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - float& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float(__a, __a_end, __err); + __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1280,64 +1087,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - double& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float(__a, __a_end, __err); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// floating point template +template _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - long double& __v) const + _Fp& __v) const { // Stage 1, nothing to do // Stage 2 @@ -1358,7 +1116,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, char __exp = 'E'; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1375,7 +1133,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_float(__a, __a_end, __err); + __v = __num_get_float<_Fp>(__a, __a_end, __err); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1408,7 +1166,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, unsigned __dc = 0; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1435,10 +1193,10 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class num_get) -_LIBCPP_EXTERN_TEMPLATE(class num_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get) -struct __num_put_base +struct _LIBCPP_TYPE_VIS __num_put_base { protected: static void __format_int(char* __fmt, const char* __len, bool __signd, @@ -1585,11 +1343,11 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, __op = __ob + (__np - __nb); } -_LIBCPP_EXTERN_TEMPLATE(struct __num_put) -_LIBCPP_EXTERN_TEMPLATE(struct __num_put) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put) template > -class _LIBCPP_TYPE_VIS num_put +class _LIBCPP_TYPE_VIS_ONLY num_put : public locale::facet, private __num_put<_CharT> { @@ -1769,7 +1527,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return do_put(__s, __iob, __fl, (unsigned long)__v); const numpunct& __np = use_facet >(__iob.getloc()); typedef typename numpunct::string_type string_type; +#if _LIBCPP_DEBUG_LEVEL >= 2 + string_type __tmp(__v ? __np.truename() : __np.falsename()); + string_type __nm = _VSTD::move(__tmp); +#else string_type __nm = __v ? __np.truename() : __np.falsename(); +#endif for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) *__s = *__i; return __s; @@ -2065,8 +1828,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class num_put) -_LIBCPP_EXTERN_TEMPLATE(class num_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put) template _LIBCPP_HIDDEN @@ -2108,7 +1871,7 @@ public: }; template -class __time_get_c_storage // purposefully not decorated +class _LIBCPP_TYPE_VIS __time_get_c_storage { protected: typedef basic_string<_CharT> string_type; @@ -2123,7 +1886,7 @@ protected: }; template > -class _LIBCPP_TYPE_VIS time_get +class _LIBCPP_TYPE_VIS_ONLY time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> @@ -2732,10 +2495,10 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class time_get) -_LIBCPP_EXTERN_TEMPLATE(class time_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get) -class __time_get +class _LIBCPP_TYPE_VIS __time_get { protected: locale_t __loc_; @@ -2746,7 +2509,7 @@ protected: }; template -class __time_get_storage +class _LIBCPP_TYPE_VIS __time_get_storage : public __time_get { protected: @@ -2773,7 +2536,7 @@ private: }; template > -class _LIBCPP_TYPE_VIS time_get_byname +class _LIBCPP_TYPE_VIS_ONLY time_get_byname : public time_get<_CharT, _InputIterator>, private __time_get_storage<_CharT> { @@ -2815,10 +2578,10 @@ private: virtual const string_type& __X() const {return this->__X_;} }; -_LIBCPP_EXTERN_TEMPLATE(class time_get_byname) -_LIBCPP_EXTERN_TEMPLATE(class time_get_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname) -class __time_put +class _LIBCPP_TYPE_VIS __time_put { locale_t __loc_; protected: @@ -2833,7 +2596,7 @@ protected: }; template > -class _LIBCPP_TYPE_VIS time_put +class _LIBCPP_TYPE_VIS_ONLY time_put : public locale::facet, private __time_put { @@ -2928,11 +2691,11 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, return _VSTD::copy(__nb, __ne, __s); } -_LIBCPP_EXTERN_TEMPLATE(class time_put) -_LIBCPP_EXTERN_TEMPLATE(class time_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put) template > -class _LIBCPP_TYPE_VIS time_put_byname +class _LIBCPP_TYPE_VIS_ONLY time_put_byname : public time_put<_CharT, _OutputIterator> { public: @@ -2949,8 +2712,8 @@ protected: ~time_put_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class time_put_byname) -_LIBCPP_EXTERN_TEMPLATE(class time_put_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname) // money_base @@ -2966,7 +2729,7 @@ public: // moneypunct template -class _LIBCPP_TYPE_VIS moneypunct +class _LIBCPP_TYPE_VIS_ONLY moneypunct : public locale::facet, public money_base { @@ -3016,15 +2779,15 @@ template const bool moneypunct<_CharT, _International>::intl; -_LIBCPP_EXTERN_TEMPLATE(class moneypunct) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct) // moneypunct_byname template -class _LIBCPP_TYPE_VIS moneypunct_byname +class _LIBCPP_TYPE_VIS_ONLY moneypunct_byname : public moneypunct<_CharT, _International> { public: @@ -3073,10 +2836,10 @@ template<> void moneypunct_byname::init(const char*); template<> void moneypunct_byname::init(const char*); template<> void moneypunct_byname::init(const char*); -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname) // money_get @@ -3132,11 +2895,11 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, } } -_LIBCPP_EXTERN_TEMPLATE(class __money_get) -_LIBCPP_EXTERN_TEMPLATE(class __money_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get) template > -class _LIBCPP_TYPE_VIS money_get +class _LIBCPP_TYPE_VIS_ONLY money_get : public locale::facet, private __money_get<_CharT> { @@ -3190,7 +2953,7 @@ template locale::id money_get<_CharT, _InputIterator>::id; -void __do_nothing(void*); +_LIBCPP_FUNC_VIS void __do_nothing(void*); template _LIBCPP_HIDDEN @@ -3320,7 +3083,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, bool __more_needed = __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast(money_base::none)); - bool __sb = __flags & ios_base::showbase; + bool __sb = (__flags & ios_base::showbase) != 0; if (__sb || __more_needed) { typename string_type::const_iterator __sym_space_end = __sym.begin(); @@ -3513,8 +3276,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class money_get) -_LIBCPP_EXTERN_TEMPLATE(class money_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get) // money_put @@ -3688,11 +3451,11 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m __mi = __mb; } -_LIBCPP_EXTERN_TEMPLATE(class __money_put) -_LIBCPP_EXTERN_TEMPLATE(class __money_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put) template > -class _LIBCPP_TYPE_VIS money_put +class _LIBCPP_TYPE_VIS_ONLY money_put : public locale::facet, private __money_put<_CharT> { @@ -3845,8 +3608,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class money_put) -_LIBCPP_EXTERN_TEMPLATE(class money_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put) // messages @@ -3859,7 +3622,7 @@ public: }; template -class _LIBCPP_TYPE_VIS messages +class _LIBCPP_TYPE_VIS_ONLY messages : public locale::facet, public messages_base { @@ -3955,11 +3718,11 @@ messages<_CharT>::do_close(catalog __c) const #endif // !_WIN32 } -_LIBCPP_EXTERN_TEMPLATE(class messages) -_LIBCPP_EXTERN_TEMPLATE(class messages) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages) template -class _LIBCPP_TYPE_VIS messages_byname +class _LIBCPP_TYPE_VIS_ONLY messages_byname : public messages<_CharT> { public: @@ -3979,13 +3742,13 @@ protected: ~messages_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class messages_byname) -_LIBCPP_EXTERN_TEMPLATE(class messages_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname) template, class _Byte_alloc = allocator > -class _LIBCPP_TYPE_VIS wstring_convert +class _LIBCPP_TYPE_VIS_ONLY wstring_convert { public: typedef basic_string, _Byte_alloc> byte_string; @@ -4003,9 +3766,9 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: - wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); wstring_convert(_Codecvt* __pcvt, state_type __state); - wstring_convert(const byte_string& __byte_err, + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES wstring_convert(wstring_convert&& __wc); @@ -4035,7 +3798,7 @@ public: byte_string to_bytes(const _Elem* __first, const _Elem* __last); _LIBCPP_ALWAYS_INLINE - size_t converted() const {return __cvtcount_;} + size_t converted() const _NOEXCEPT {return __cvtcount_;} _LIBCPP_ALWAYS_INLINE state_type state() const {return __cvtstate_;} }; @@ -4238,7 +4001,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: } template > -class _LIBCPP_TYPE_VIS wbuffer_convert +class _LIBCPP_TYPE_VIS_ONLY wbuffer_convert : public basic_streambuf<_Elem, _Tr> { public: @@ -4269,8 +4032,8 @@ private: wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); public: - wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, - state_type __state = state_type()); + _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, + _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/map b/contrib/libc++/include/map index 953743a6c..009e8e216 100644 --- a/contrib/libc++/include/map +++ b/contrib/libc++/include/map @@ -77,7 +77,12 @@ public: map(map&& m, const allocator_type& a); map(initializer_list il, const key_compare& comp = key_compare()); map(initializer_list il, const key_compare& comp, const allocator_type& a); - ~map(); + template + map(InputIterator first, InputIterator last, const allocator_type& a) + : map(first, last, Compare(), a) {} // C++14 + map(initializer_list il, const allocator_type& a) + : map(il, Compare(), a) {} // C++14 + ~map(); map& operator=(const map& m); map& operator=(map&& m) @@ -149,13 +154,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template + iterator find(const K& x); // C++14 + template + const_iterator find(const K& x) const; // C++14 + template + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template + iterator lower_bound(const K& x); // C++14 + template + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template + iterator upper_bound(const K& x); // C++14 + template + const_iterator upper_bound(const K& x) const; // C++14 + pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; + template + pair equal_range(const K& x); // C++14 + template + pair equal_range(const K& x) const; // C++14 }; template @@ -252,6 +278,11 @@ public: multimap(initializer_list il, const key_compare& comp = key_compare()); multimap(initializer_list il, const key_compare& comp, const allocator_type& a); + template + multimap(InputIterator first, InputIterator last, const allocator_type& a) + : multimap(first, last, Compare(), a) {} // C++14 + multimap(initializer_list il, const allocator_type& a) + : multimap(il, Compare(), a) {} // C++14 ~multimap(); multimap& operator=(const multimap& m); @@ -317,13 +348,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template + iterator find(const K& x); // C++14 + template + const_iterator find(const K& x) const; // C++14 + template + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template + iterator lower_bound(const K& x); // C++14 + template + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template + iterator upper_bound(const K& x); // C++14 + template + const_iterator upper_bound(const K& x) const; // C++14 + pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; + template + pair equal_range(const K& x); // C++14 + template + pair equal_range(const K& x) const; // C++14 }; template @@ -409,6 +461,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return static_cast(*this)(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return static_cast(*this) (__x, __y.__cc.first);} + + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return static_cast(*this) (__x.__cc.first, __y);} +#endif }; template @@ -437,6 +503,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return comp(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return comp (__x, __y.__cc.first);} + + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return comp (__x.__cc.first, __y);} +#endif }; template @@ -495,8 +575,77 @@ template class multimap; template class __map_const_iterator; +#if __cplusplus >= 201103L + +template +union __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair value_type; + typedef pair __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template + _LIBCPP_INLINE_VISIBILITY + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(const __value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__value_type() {__cc.~value_type();} +}; + +#else + +template +struct __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __value_type() {} + + template + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template -class _LIBCPP_TYPE_VIS __map_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_iterator { _TreeIterator __i_; @@ -555,13 +704,13 @@ public: bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS map; - template friend class _LIBCPP_TYPE_VIS multimap; - template friend class _LIBCPP_TYPE_VIS __map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY map; + template friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template -class _LIBCPP_TYPE_VIS __map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator { _TreeIterator __i_; @@ -624,14 +773,14 @@ public: bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS map; - template friend class _LIBCPP_TYPE_VIS multimap; - template friend class _LIBCPP_TYPE_VIS __tree_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY map; + template friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; }; template , class _Allocator = allocator > > -class _LIBCPP_TYPE_VIS map +class _LIBCPP_TYPE_VIS_ONLY map { public: // types: @@ -644,7 +793,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { friend class map; @@ -660,49 +809,7 @@ public: private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename map::value_type value_type; - typedef typename map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename map::value_type value_type; - value_type __cc; - - __value_type() {} - - template - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type __value_type; typedef __map_value_compare __vc; typedef typename allocator_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -757,6 +864,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : map(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map(const map& __m) : __tree_(__m.__tree_) @@ -815,6 +929,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + map(initializer_list __il, const allocator_type& __a) + : map(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map& operator=(initializer_list __il) { @@ -961,6 +1081,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} @@ -970,18 +1101,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) {return __tree_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} +#endif private: typedef typename __base::__node __node; @@ -1152,7 +1316,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1186,7 +1350,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template @@ -1346,7 +1510,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, template , class _Allocator = allocator > > -class _LIBCPP_TYPE_VIS multimap +class _LIBCPP_TYPE_VIS_ONLY multimap { public: // types: @@ -1359,7 +1523,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { friend class multimap; @@ -1375,49 +1539,8 @@ public: }; private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename multimap::value_type value_type; - typedef typename multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type __value_type; typedef __map_value_compare __vc; typedef typename allocator_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -1472,6 +1595,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multimap(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap(const multimap& __m) : __tree_(__m.__tree_.value_comp(), @@ -1531,6 +1661,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multimap(initializer_list __il, const allocator_type& __a) + : multimap(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap& operator=(initializer_list __il) { @@ -1666,6 +1802,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} @@ -1675,18 +1822,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) {return __tree_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} +#endif private: typedef typename __base::__node __node; diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index 345154638..b382f70b0 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -90,7 +90,7 @@ struct allocator_traits template static void destroy(allocator_type& a, T* p); - static size_type max_size(const allocator_type& a); + static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); @@ -496,8 +496,8 @@ public: long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; - template bool owner_before(shared_ptr const& b); - template bool owner_before(weak_ptr const& b); + template bool owner_before(shared_ptr const& b) const; + template bool owner_before(weak_ptr const& b) const; }; // weak_ptr specialized algorithms: @@ -618,60 +618,12 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); _LIBCPP_BEGIN_NAMESPACE_STD -// addressof - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return (_Tp*)&reinterpret_cast(__x); -} - -#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) -// Objective-C++ Automatic Reference Counting uses qualified pointers -// that require special addressof() signatures. When -// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler -// itself is providing these definitions. Otherwise, we provide them. -template -inline _LIBCPP_INLINE_VISIBILITY -__strong _Tp* -addressof(__strong _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK -template -inline _LIBCPP_INLINE_VISIBILITY -__weak _Tp* -addressof(__weak _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -__autoreleasing _Tp* -addressof(__autoreleasing _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__unsafe_unretained _Tp* -addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif +// addressof moved to <__functional_base> template class allocator; template <> -class _LIBCPP_TYPE_VIS allocator +class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef void* pointer; @@ -682,7 +634,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS allocator +class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef const void* pointer; @@ -917,7 +869,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> #endif // _LIBCPP_HAS_NO_VARIADICS template -struct _LIBCPP_TYPE_VIS pointer_traits +struct _LIBCPP_TYPE_VIS_ONLY pointer_traits { typedef _Ptr pointer; typedef typename __pointer_traits_element_type::type element_type; @@ -940,7 +892,7 @@ public: }; template -struct _LIBCPP_TYPE_VIS pointer_traits<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> { typedef _Tp* pointer; typedef _Tp element_type; @@ -1447,7 +1399,7 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> }; template -struct _LIBCPP_TYPE_VIS allocator_traits +struct _LIBCPP_TYPE_VIS_ONLY allocator_traits { typedef _Alloc allocator_type; typedef typename allocator_type::value_type value_type; @@ -1531,7 +1483,7 @@ struct _LIBCPP_TYPE_VIS allocator_traits {__destroy(__has_destroy(), __a, __p);} _LIBCPP_INLINE_VISIBILITY - static size_type max_size(const allocator_type& __a) + static size_type max_size(const allocator_type& __a) _NOEXCEPT {return __max_size(__has_max_size(), __a);} _LIBCPP_INLINE_VISIBILITY @@ -1653,7 +1605,7 @@ private: // allocator template -class _LIBCPP_TYPE_VIS allocator +class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef size_t size_type; @@ -1745,7 +1697,7 @@ public: }; template -class _LIBCPP_TYPE_VIS allocator +class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef size_t size_type; @@ -1843,7 +1795,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} template -class _LIBCPP_TYPE_VIS raw_storage_iterator +class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator : public iterator -class _LIBCPP_TYPE_VIS auto_ptr +class _LIBCPP_TYPE_VIS_ONLY auto_ptr { private: _Tp* __ptr_; @@ -1940,7 +1892,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS auto_ptr +class _LIBCPP_TYPE_VIS_ONLY auto_ptr { public: typedef void element_type; @@ -2002,7 +1954,7 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} -#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) @@ -2021,8 +1973,6 @@ public: return *this; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && @@ -2040,9 +1990,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2099,7 +2047,7 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} -#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) @@ -2117,8 +2065,6 @@ public: return *this; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && @@ -2135,9 +2081,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2195,7 +2139,7 @@ public: is_nothrow_move_constructible<_T2>::value) : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} -#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) @@ -2213,8 +2157,6 @@ public: return *this; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && @@ -2231,9 +2173,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2289,7 +2229,7 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} -#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) @@ -2307,8 +2247,6 @@ public: return *this; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && @@ -2325,9 +2263,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2380,7 +2316,7 @@ public: _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} -#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) _LIBCPP_INLINE_VISIBILITY __compressed_pair(const __compressed_pair& __p) @@ -2397,7 +2333,6 @@ public: return *this; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY __compressed_pair(__compressed_pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && @@ -2413,9 +2348,7 @@ public: return *this; } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2476,7 +2409,7 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> // default_delete template -struct _LIBCPP_TYPE_VIS default_delete +struct _LIBCPP_TYPE_VIS_ONLY default_delete { #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; @@ -2495,7 +2428,7 @@ struct _LIBCPP_TYPE_VIS default_delete }; template -struct _LIBCPP_TYPE_VIS default_delete<_Tp[]> +struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> { public: #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2518,7 +2451,7 @@ public: }; template > -class _LIBCPP_TYPE_VIS unique_ptr +class _LIBCPP_TYPE_VIS_ONLY unique_ptr { public: typedef _Tp element_type; @@ -2697,7 +2630,7 @@ public: }; template -class _LIBCPP_TYPE_VIS unique_ptr<_Tp[], _Dp> +class _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp> { public: typedef _Tp element_type; @@ -3452,7 +3385,7 @@ struct __scalar_hash<_Tp, 4> }; template -struct _LIBCPP_TYPE_VIS hash<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> : public unary_function<_Tp*, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -3469,7 +3402,7 @@ struct _LIBCPP_TYPE_VIS hash<_Tp*> }; template -struct _LIBCPP_TYPE_VIS hash > +struct _LIBCPP_TYPE_VIS_ONLY hash > { typedef unique_ptr<_Tp, _Dp> argument_type; typedef size_t result_type; @@ -3642,9 +3575,9 @@ public: virtual const char* what() const _NOEXCEPT; }; -template class _LIBCPP_TYPE_VIS weak_ptr; +template class _LIBCPP_TYPE_VIS_ONLY weak_ptr; -class __shared_count +class _LIBCPP_TYPE_VIS __shared_count { __shared_count(const __shared_count&); __shared_count& operator=(const __shared_count&); @@ -3666,7 +3599,7 @@ public: long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} }; -class __shared_weak_count +class _LIBCPP_TYPE_VIS __shared_weak_count : private __shared_count { long __shared_weak_owners_; @@ -3811,10 +3744,10 @@ __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT __a.deallocate(this, 1); } -template class _LIBCPP_TYPE_VIS enable_shared_from_this; +template class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; template -class _LIBCPP_TYPE_VIS shared_ptr +class _LIBCPP_TYPE_VIS_ONLY shared_ptr { public: typedef _Tp element_type; @@ -3943,8 +3876,8 @@ public: < !is_array<_Yp>::value && is_convertible<_Yp*, element_type*>::value, - shared_ptr& - >::type + shared_ptr + >::type& operator=(auto_ptr<_Yp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template @@ -4083,8 +4016,8 @@ private: _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(const void*) _NOEXCEPT {} - template friend class _LIBCPP_TYPE_VIS shared_ptr; - template friend class _LIBCPP_TYPE_VIS weak_ptr; + template friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; + template friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; }; template @@ -4570,8 +4503,8 @@ typename enable_if < !is_array<_Yp>::value && is_convertible<_Yp*, _Tp*>::value, - shared_ptr<_Tp>& ->::type + shared_ptr<_Tp> +>::type& shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) { shared_ptr(_VSTD::move(__r)).swap(*this); @@ -4980,7 +4913,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT #endif // _LIBCPP_NO_RTTI template -class _LIBCPP_TYPE_VIS weak_ptr +class _LIBCPP_TYPE_VIS_ONLY weak_ptr { public: typedef _Tp element_type; @@ -5055,8 +4988,8 @@ public: bool owner_before(const weak_ptr<_Up>& __r) const {return __cntrl_ < __r.__cntrl_;} - template friend class _LIBCPP_TYPE_VIS weak_ptr; - template friend class _LIBCPP_TYPE_VIS shared_ptr; + template friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; + template friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; }; template @@ -5256,7 +5189,7 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT template struct owner_less; template -struct _LIBCPP_TYPE_VIS owner_less > +struct _LIBCPP_TYPE_VIS_ONLY owner_less > : binary_function, shared_ptr<_Tp>, bool> { typedef bool result_type; @@ -5272,7 +5205,7 @@ struct _LIBCPP_TYPE_VIS owner_less > }; template -struct _LIBCPP_TYPE_VIS owner_less > +struct _LIBCPP_TYPE_VIS_ONLY owner_less > : binary_function, weak_ptr<_Tp>, bool> { typedef bool result_type; @@ -5288,7 +5221,7 @@ struct _LIBCPP_TYPE_VIS owner_less > }; template -class _LIBCPP_TYPE_VIS enable_shared_from_this +class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this { mutable weak_ptr<_Tp> __weak_this_; protected: @@ -5313,7 +5246,7 @@ public: }; template -struct _LIBCPP_TYPE_VIS hash > +struct _LIBCPP_TYPE_VIS_ONLY hash > { typedef shared_ptr<_Tp> argument_type; typedef size_t result_type; @@ -5331,7 +5264,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); #if __has_feature(cxx_atomic) -class __sp_mut +class _LIBCPP_TYPE_VIS __sp_mut { void* __lx; public: @@ -5475,11 +5408,11 @@ struct _LIBCPP_TYPE_VIS pointer_safety operator int() const {return __v_;} }; -void declare_reachable(void* __p); -void declare_no_pointers(char* __p, size_t __n); -void undeclare_no_pointers(char* __p, size_t __n); -pointer_safety get_pointer_safety() _NOEXCEPT; -void* __undeclare_reachable(void* __p); +_LIBCPP_FUNC_VIS void declare_reachable(void* __p); +_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); +_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); +_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT; +_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); template inline _LIBCPP_INLINE_VISIBILITY @@ -5489,7 +5422,7 @@ undeclare_reachable(_Tp* __p) return static_cast<_Tp*>(__undeclare_reachable(__p)); } -void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); +_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/mutex b/contrib/libc++/include/mutex index e2b5d6bfd..e0c02adb5 100644 --- a/contrib/libc++/include/mutex +++ b/contrib/libc++/include/mutex @@ -441,7 +441,7 @@ void call_once(once_flag&, _Callable); #endif // _LIBCPP_HAS_NO_VARIADICS -struct _LIBCPP_TYPE_VIS once_flag +struct _LIBCPP_TYPE_VIS_ONLY once_flag { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR @@ -527,7 +527,7 @@ __call_once_proxy(void* __vp) (*__p)(); } -void __call_once(volatile unsigned long&, void*, void(*)(void*)); +_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); #ifndef _LIBCPP_HAS_NO_VARIADICS diff --git a/contrib/libc++/include/new b/contrib/libc++/include/new index 1e85798b5..ea4a4a01a 100644 --- a/contrib/libc++/include/new +++ b/contrib/libc++/include/new @@ -27,6 +27,18 @@ public: virtual const char* what() const noexcept; }; +class bad_array_length : public bad_alloc // C++14 +{ +public: + bad_array_length() noexcept; +}; + +class bad_array_new_length : public bad_alloc +{ +public: + bad_array_new_length() noexcept; +}; + struct nothrow_t {}; extern const nothrow_t nothrow; typedef void (*new_handler)(); @@ -81,7 +93,22 @@ public: virtual const char* what() const _NOEXCEPT; }; -void __throw_bad_alloc(); // not in C++ spec +#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) + +class _LIBCPP_EXCEPTION_ABI bad_array_length + : public bad_alloc +{ +public: + bad_array_length() _NOEXCEPT; + virtual ~bad_array_length() _NOEXCEPT; + virtual const char* what() const _NOEXCEPT; +}; + +#define _LIBCPP_BAD_ARRAY_LENGTH_DEFINED + +#endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) + +_LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec struct _LIBCPP_TYPE_VIS nothrow_t {}; extern _LIBCPP_FUNC_VIS const nothrow_t nothrow; @@ -91,27 +118,33 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; } // std -_LIBCPP_FUNC_VIS void* operator new(std::size_t __sz) +#if defined(_WIN32) && !defined(cxx_EXPORTS) +# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS_ONLY +#else +# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS +#endif + +_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif ; -_LIBCPP_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; -_LIBCPP_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; -_LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz) +_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif ; -_LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; -_LIBCPP_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; - -_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) _NOEXCEPT {} -_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) _NOEXCEPT {} +_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; + +inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {} +inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {} #endif // _LIBCPP_NEW diff --git a/contrib/libc++/include/numeric b/contrib/libc++/include/numeric index c201a5f57..e520c8e0d 100644 --- a/contrib/libc++/include/numeric +++ b/contrib/libc++/include/numeric @@ -157,7 +157,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __t2 - __t1; - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; @@ -177,7 +177,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __binary_op(__t2, __t1); - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; diff --git a/contrib/libc++/include/ostream b/contrib/libc++/include/ostream index eac9c8f02..041314acc 100644 --- a/contrib/libc++/include/ostream +++ b/contrib/libc++/include/ostream @@ -32,6 +32,7 @@ public: virtual ~basic_ostream(); // 27.7.2.3 Assign/swap + basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14 basic_ostream& operator=(basic_ostream&& rhs); void swap(basic_ostream& rhs); @@ -140,7 +141,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD template -class _LIBCPP_TYPE_VIS basic_ostream +class _LIBCPP_TYPE_VIS_ONLY basic_ostream : virtual public basic_ios<_CharT, _Traits> { public: @@ -161,6 +162,9 @@ 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); @@ -169,7 +173,7 @@ protected: public: // 27.7.2.4 Prefix/suffix: - class _LIBCPP_TYPE_VIS sentry; + class _LIBCPP_TYPE_VIS_ONLY sentry; // 27.7.2.6 Formatted output: basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)); @@ -207,7 +211,7 @@ protected: }; template -class _LIBCPP_TYPE_VIS basic_ostream<_CharT, _Traits>::sentry +class _LIBCPP_TYPE_VIS_ONLY basic_ostream<_CharT, _Traits>::sentry { bool __ok_; basic_ostream<_CharT, _Traits>& __os_; @@ -1155,7 +1159,8 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { - if (!this->fail()) + sentry __s(*this); + if (__s) { if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) this->setstate(ios_base::failbit); @@ -1168,8 +1173,12 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { - if (!this->fail()) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); + sentry __s(*this); + if (__s) + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) + this->setstate(ios_base::failbit); + } return *this; } @@ -1278,8 +1287,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) use_facet >(__os.getloc()).widen('1')); } -_LIBCPP_EXTERN_TEMPLATE(class basic_ostream) -_LIBCPP_EXTERN_TEMPLATE(class basic_ostream) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/queue b/contrib/libc++/include/queue index 8d1a9dfc9..bdfd70603 100644 --- a/contrib/libc++/include/queue +++ b/contrib/libc++/include/queue @@ -177,7 +177,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS queue; +template class _LIBCPP_TYPE_VIS_ONLY queue; template _LIBCPP_INLINE_VISIBILITY @@ -190,7 +190,7 @@ bool operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); template > -class _LIBCPP_TYPE_VIS queue +class _LIBCPP_TYPE_VIS_ONLY queue { public: typedef _Container container_type; @@ -376,14 +376,14 @@ swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) } template -struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : public uses_allocator<_Container, _Alloc> { }; template , class _Compare = less > -class _LIBCPP_TYPE_VIS priority_queue +class _LIBCPP_TYPE_VIS_ONLY priority_queue { public: typedef _Container container_type; @@ -707,7 +707,7 @@ swap(priority_queue<_Tp, _Container, _Compare>& __x, } template -struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : public uses_allocator<_Container, _Alloc> { }; diff --git a/contrib/libc++/include/random b/contrib/libc++/include/random index 46cbc4bdc..c0db1abac 100644 --- a/contrib/libc++/include/random +++ b/contrib/libc++/include/random @@ -1813,7 +1813,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> }; template -class _LIBCPP_TYPE_VIS linear_congruential_engine; +class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine; template @@ -1829,7 +1829,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); template -class _LIBCPP_TYPE_VIS linear_congruential_engine +class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine { public: // types @@ -1973,33 +1973,6 @@ linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; } -template -class __save_flags -{ - typedef basic_ios<_CharT, _Traits> __stream_type; - typedef typename __stream_type::fmtflags fmtflags; - - __stream_type& __stream_; - fmtflags __fmtflags_; - _CharT __fill_; - - __save_flags(const __save_flags&); - __save_flags& operator=(const __save_flags&); -public: - _LIBCPP_INLINE_VISIBILITY - explicit __save_flags(__stream_type& __stream) - : __stream_(__stream), - __fmtflags_(__stream.flags()), - __fill_(__stream.fill()) - {} - _LIBCPP_INLINE_VISIBILITY - ~__save_flags() - { - __stream_.flags(__fmtflags_); - __stream_.fill(__fill_); - } -}; - template inline _LIBCPP_INLINE_VISIBILITY @@ -2038,7 +2011,7 @@ typedef minstd_rand default_random_engine; template -class _LIBCPP_TYPE_VIS mersenne_twister_engine; +class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine; template >(basic_istream<_CharT, _Traits>& __is, template -class _LIBCPP_TYPE_VIS mersenne_twister_engine +class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine { public: // types @@ -2526,7 +2499,7 @@ typedef mersenne_twister_engine -class _LIBCPP_TYPE_VIS subtract_with_carry_engine; +class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine; template bool @@ -2554,7 +2527,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); template -class _LIBCPP_TYPE_VIS subtract_with_carry_engine +class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine { public: // types @@ -2837,7 +2810,7 @@ typedef subtract_with_carry_engine ranlux48_base; // discard_block_engine template -class _LIBCPP_TYPE_VIS discard_block_engine +class _LIBCPP_TYPE_VIS_ONLY discard_block_engine { _Engine __e_; int __n_; @@ -3010,7 +2983,7 @@ typedef discard_block_engine ranlux48; // independent_bits_engine template -class _LIBCPP_TYPE_VIS independent_bits_engine +class _LIBCPP_TYPE_VIS_ONLY independent_bits_engine { template class __get_n @@ -3273,7 +3246,7 @@ public: }; template -class _LIBCPP_TYPE_VIS shuffle_order_engine +class _LIBCPP_TYPE_VIS_ONLY shuffle_order_engine { static_assert(0 < __k, "shuffle_order_engine invalid parameters"); public: @@ -3502,7 +3475,9 @@ typedef shuffle_order_engine knuth_b; class _LIBCPP_TYPE_VIS random_device { +#if !defined(_WIN32) int __f_; +#endif // defined(_WIN32) public: // types typedef unsigned result_type; @@ -3534,7 +3509,7 @@ private: // seed_seq -class _LIBCPP_TYPE_VIS seed_seq +class _LIBCPP_TYPE_VIS_ONLY seed_seq { public: // types @@ -3548,7 +3523,7 @@ private: public: // constructors _LIBCPP_INLINE_VISIBILITY - seed_seq() {} + seed_seq() _NOEXCEPT {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY @@ -3566,7 +3541,7 @@ public: // property functions _LIBCPP_INLINE_VISIBILITY - size_t size() const {return __v_.size();} + size_t size() const _NOEXCEPT {return __v_.size();} template _LIBCPP_INLINE_VISIBILITY void param(_OutputIterator __dest) const @@ -3711,13 +3686,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // uniform_real_distribution template -class _LIBCPP_TYPE_VIS uniform_real_distribution +class _LIBCPP_TYPE_VIS_ONLY uniform_real_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -3832,13 +3807,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // bernoulli_distribution -class _LIBCPP_TYPE_VIS bernoulli_distribution +class _LIBCPP_TYPE_VIS_ONLY bernoulli_distribution { public: // types typedef bool result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: @@ -3941,13 +3916,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x) // binomial_distribution template -class _LIBCPP_TYPE_VIS binomial_distribution +class _LIBCPP_TYPE_VIS_ONLY binomial_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __t_; double __p_; @@ -4106,13 +4081,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // exponential_distribution template -class _LIBCPP_TYPE_VIS exponential_distribution +class _LIBCPP_TYPE_VIS_ONLY exponential_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __lambda_; public: @@ -4221,13 +4196,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // normal_distribution template -class _LIBCPP_TYPE_VIS normal_distribution +class _LIBCPP_TYPE_VIS_ONLY normal_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __mean_; result_type __stddev_; @@ -4389,13 +4364,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // lognormal_distribution template -class _LIBCPP_TYPE_VIS lognormal_distribution +class _LIBCPP_TYPE_VIS_ONLY lognormal_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { normal_distribution __nd_; public: @@ -4514,13 +4489,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // poisson_distribution template -class _LIBCPP_TYPE_VIS poisson_distribution +class _LIBCPP_TYPE_VIS_ONLY poisson_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __mean_; double __s_; @@ -4745,13 +4720,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // weibull_distribution template -class _LIBCPP_TYPE_VIS weibull_distribution +class _LIBCPP_TYPE_VIS_ONLY weibull_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -4859,13 +4834,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, } template -class _LIBCPP_TYPE_VIS extreme_value_distribution +class _LIBCPP_TYPE_VIS_ONLY extreme_value_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -4980,13 +4955,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // gamma_distribution template -class _LIBCPP_TYPE_VIS gamma_distribution +class _LIBCPP_TYPE_VIS_ONLY gamma_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __alpha_; result_type __beta_; @@ -5152,13 +5127,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // negative_binomial_distribution template -class _LIBCPP_TYPE_VIS negative_binomial_distribution +class _LIBCPP_TYPE_VIS_ONLY negative_binomial_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __k_; double __p_; @@ -5287,13 +5262,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // geometric_distribution template -class _LIBCPP_TYPE_VIS geometric_distribution +class _LIBCPP_TYPE_VIS_ONLY geometric_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: @@ -5389,13 +5364,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // chi_squared_distribution template -class _LIBCPP_TYPE_VIS chi_squared_distribution +class _LIBCPP_TYPE_VIS_ONLY chi_squared_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: @@ -5495,13 +5470,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // cauchy_distribution template -class _LIBCPP_TYPE_VIS cauchy_distribution +class _LIBCPP_TYPE_VIS_ONLY cauchy_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -5618,13 +5593,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // fisher_f_distribution template -class _LIBCPP_TYPE_VIS fisher_f_distribution +class _LIBCPP_TYPE_VIS_ONLY fisher_f_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __m_; result_type __n_; @@ -5740,13 +5715,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // student_t_distribution template -class _LIBCPP_TYPE_VIS student_t_distribution +class _LIBCPP_TYPE_VIS_ONLY student_t_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: @@ -5853,13 +5828,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // discrete_distribution template -class _LIBCPP_TYPE_VIS discrete_distribution +class _LIBCPP_TYPE_VIS_ONLY discrete_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector __p_; public: @@ -5928,8 +5903,8 @@ public: discrete_distribution(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} - explicit discrete_distribution(const param_type& __p) _LIBCPP_INLINE_VISIBILITY + explicit discrete_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} @@ -6084,13 +6059,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // piecewise_constant_distribution template -class _LIBCPP_TYPE_VIS piecewise_constant_distribution +class _LIBCPP_TYPE_VIS_ONLY piecewise_constant_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector __b_; vector __densities_; @@ -6408,13 +6383,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // piecewise_linear_distribution template -class _LIBCPP_TYPE_VIS piecewise_linear_distribution +class _LIBCPP_TYPE_VIS_ONLY piecewise_linear_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector __b_; vector __densities_; diff --git a/contrib/libc++/include/ratio b/contrib/libc++/include/ratio index f4e741e84..48dcd81c1 100644 --- a/contrib/libc++/include/ratio +++ b/contrib/libc++/include/ratio @@ -231,7 +231,7 @@ public: }; template -class _LIBCPP_TYPE_VIS ratio +class _LIBCPP_TYPE_VIS_ONLY ratio { static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range"); static_assert(_Den != 0, "ratio divide by 0"); @@ -292,7 +292,7 @@ template using ratio_multiply #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template -struct _LIBCPP_TYPE_VIS ratio_multiply +struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -319,7 +319,7 @@ template using ratio_divide #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template -struct _LIBCPP_TYPE_VIS ratio_divide +struct _LIBCPP_TYPE_VIS_ONLY ratio_divide : public __ratio_divide<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -354,7 +354,7 @@ template using ratio_add #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template -struct _LIBCPP_TYPE_VIS ratio_add +struct _LIBCPP_TYPE_VIS_ONLY ratio_add : public __ratio_add<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -389,7 +389,7 @@ template using ratio_subtract #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template -struct _LIBCPP_TYPE_VIS ratio_subtract +struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -397,11 +397,11 @@ struct _LIBCPP_TYPE_VIS ratio_subtract // ratio_equal template -struct _LIBCPP_TYPE_VIS ratio_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_equal : public integral_constant {}; template -struct _LIBCPP_TYPE_VIS ratio_not_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal : public integral_constant::value> {}; // ratio_less @@ -460,19 +460,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> }; template -struct _LIBCPP_TYPE_VIS ratio_less +struct _LIBCPP_TYPE_VIS_ONLY ratio_less : public integral_constant::value> {}; template -struct _LIBCPP_TYPE_VIS ratio_less_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal : public integral_constant::value> {}; template -struct _LIBCPP_TYPE_VIS ratio_greater +struct _LIBCPP_TYPE_VIS_ONLY ratio_greater : public integral_constant::value> {}; template -struct _LIBCPP_TYPE_VIS ratio_greater_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal : public integral_constant::value> {}; template diff --git a/contrib/libc++/include/regex b/contrib/libc++/include/regex index 312ca1144..ffe39cf1c 100644 --- a/contrib/libc++/include/regex +++ b/contrib/libc++/include/regex @@ -925,7 +925,7 @@ public: }; template -struct _LIBCPP_TYPE_VIS regex_traits +struct _LIBCPP_TYPE_VIS_ONLY regex_traits { public: typedef _CharT char_type; @@ -970,7 +970,7 @@ public: bool isctype(char_type __c, char_class_type __m) const; _LIBCPP_INLINE_VISIBILITY int value(char_type __ch, int __radix) const - {return __value(__ch, __radix);} + {return __regex_traits_value(__ch, __radix);} locale_type imbue(locale_type __l); _LIBCPP_INLINE_VISIBILITY locale_type getloc()const {return __loc_;} @@ -1001,11 +1001,11 @@ private: __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; - static int __value(unsigned char __ch, int __radix); + static int __regex_traits_value(unsigned char __ch, int __radix); _LIBCPP_INLINE_VISIBILITY - int __value(char __ch, int __radix) const - {return __value(static_cast(__ch), __radix);} - int __value(wchar_t __ch, int __radix) const; + int __regex_traits_value(char __ch, int __radix) const + {return __regex_traits_value(static_cast(__ch), __radix);} + int __regex_traits_value(wchar_t __ch, int __radix) const; }; template @@ -1100,7 +1100,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, // lookup_collatename is very FreeBSD-specific -string __get_collation_name(const char* __s); +_LIBCPP_FUNC_VIS string __get_collation_name(const char* __s); template template @@ -1161,7 +1161,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, // lookup_classname -ctype_base::mask __get_classname(const char* __s, bool __icase); +ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase); template template @@ -1207,7 +1207,7 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const template int -regex_traits<_CharT>::__value(unsigned char __ch, int __radix) +regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) { if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' return __ch - '0'; @@ -1228,18 +1228,18 @@ regex_traits<_CharT>::__value(unsigned char __ch, int __radix) template inline _LIBCPP_INLINE_VISIBILITY int -regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const +regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { - return __value(static_cast(__ct_->narrow(__ch, char_type())), __radix); + return __regex_traits_value(static_cast(__ct_->narrow(__ch, char_type())), __radix); } template class __node; -template class _LIBCPP_TYPE_VIS sub_match; +template class _LIBCPP_TYPE_VIS_ONLY sub_match; template > > -class _LIBCPP_TYPE_VIS match_results; +class _LIBCPP_TYPE_VIS_ONLY match_results; template struct __state @@ -2014,6 +2014,9 @@ public: virtual void __exec(__state&) const; }; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline::__exec(__state&) const; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline::__exec(__state&) const; + // __match_char template @@ -2415,7 +2418,7 @@ __exit: template class __lookahead; template > -class _LIBCPP_TYPE_VIS basic_regex +class _LIBCPP_TYPE_VIS_ONLY basic_regex { public: // types: @@ -2769,7 +2772,7 @@ private: void __push_end_marked_subexpression(unsigned); void __push_empty(); void __push_word_boundary(bool); - void __push_lookahead(const basic_regex&, bool); + void __push_lookahead(const basic_regex&, bool, unsigned); template bool @@ -2907,6 +2910,7 @@ class __lookahead typedef __owns_one_state<_CharT> base; basic_regex<_CharT, _Traits> __exp_; + unsigned __mexp_; bool __invert_; __lookahead(const __lookahead&); @@ -2915,8 +2919,8 @@ public: typedef _VSTD::__state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY - __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s) - : base(__s), __exp_(__exp), __invert_(__invert) {} + __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) + : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {} virtual void __exec(__state&) const; }; @@ -2935,6 +2939,9 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const { __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); + for (unsigned __i = 1; __i < __m.size(); ++__i) { + __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i]; + } } else { @@ -3778,7 +3785,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, } __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -3786,7 +3793,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, __ml->__add_digraph(__start_range[0], __start_range[1]); } } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -4168,7 +4175,9 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, basic_regex __exp; __exp.__flags_ = __flags_; __temp = __exp.__parse(++__temp, __last); - __push_lookahead(_VSTD::move(__exp), false); + unsigned __mexp = __exp.__marked_count_; + __push_lookahead(_VSTD::move(__exp), false, __marked_count_); + __marked_count_ += __mexp; #ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') throw regex_error(regex_constants::error_paren); @@ -4181,7 +4190,9 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, basic_regex __exp; __exp.__flags_ = __flags_; __temp = __exp.__parse(++__temp, __last); - __push_lookahead(_VSTD::move(__exp), true); + unsigned __mexp = __exp.__marked_count_; + __push_lookahead(_VSTD::move(__exp), true, __marked_count_); + __marked_count_ += __mexp; #ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') throw regex_error(regex_constants::error_paren); @@ -4418,7 +4429,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, case 'c': if ((__t = _VSTD::next(__first)) != __last) { - if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z') + if (('A' <= *__t && *__t <= 'Z') || + ('a' <= *__t && *__t <= 'z')) { if (__str) *__str = _CharT(*__t % 32); @@ -4426,7 +4438,15 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(*__t % 32)); __first = ++__t; } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS break; case 'u': ++__first; @@ -4750,10 +4770,11 @@ basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate) template void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, - bool __invert) + bool __invert, + unsigned __mexp) { __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert, - __end_->first()); + __end_->first(), __mexp); __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); } @@ -4763,7 +4784,7 @@ typedef basic_regex wregex; // sub_match template -class _LIBCPP_TYPE_VIS sub_match +class _LIBCPP_TYPE_VIS_ONLY sub_match : public pair<_BidirectionalIterator, _BidirectionalIterator> { public: @@ -5186,7 +5207,7 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) } template -class _LIBCPP_TYPE_VIS match_results +class _LIBCPP_TYPE_VIS_ONLY match_results { public: typedef _Allocator allocator_type; @@ -5773,7 +5794,8 @@ basic_regex<_CharT, _Traits>::__search( { __m.__init(1 + mark_count(), __first, __last, __flags & regex_constants::__no_update_pos); - if (__match_at_start(__first, __last, __m, __flags, true)) + if (__match_at_start(__first, __last, __m, __flags, + !(__flags & regex_constants::__no_update_pos))) { __m.__prefix_.second = __m[0].first; __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; @@ -5810,9 +5832,10 @@ regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, const basic_regex<_CharT, _Traits>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) { - basic_string<_CharT> __s(__first, __last); + int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0; + basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last); match_results __mc; - bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); + bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags); __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); return __r; } @@ -5987,7 +6010,7 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, template ::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS regex_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; @@ -6099,7 +6122,7 @@ typedef regex_iterator wsregex_iterator; template ::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS regex_token_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; diff --git a/contrib/libc++/include/scoped_allocator b/contrib/libc++/include/scoped_allocator index 925323420..aa8bece6d 100644 --- a/contrib/libc++/include/scoped_allocator +++ b/contrib/libc++/include/scoped_allocator @@ -365,7 +365,7 @@ struct __outermost<_Alloc, true> }; template -class _LIBCPP_TYPE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> +class _LIBCPP_TYPE_VIS_ONLY scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; diff --git a/contrib/libc++/include/set b/contrib/libc++/include/set index 11ea9658b..a537c5fe3 100644 --- a/contrib/libc++/include/set +++ b/contrib/libc++/include/set @@ -66,6 +66,11 @@ public: set(initializer_list il, const value_compare& comp = value_compare()); set(initializer_list il, const value_compare& comp, const allocator_type& a); + template + set(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + set(initializer_list il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~set(); set& operator=(const set& s); @@ -129,13 +134,33 @@ public: // set operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template + iterator find(const K& x); + template + const_iterator find(const K& x) const; // C++14 + template + size_type count(const K& x) const; // C++14 + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template + iterator lower_bound(const K& x); // C++14 + template + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template + iterator upper_bound(const K& x); // C++14 + template + const_iterator upper_bound(const K& x) const; // C++14 pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; + template + pair equal_range(const K& x); // C++14 + template + pair equal_range(const K& x) const; // C++14 }; template @@ -222,6 +247,11 @@ public: multiset(initializer_list il, const value_compare& comp = value_compare()); multiset(initializer_list il, const value_compare& comp, const allocator_type& a); + template + multiset(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + multiset(initializer_list il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~multiset(); multiset& operator=(const multiset& s); @@ -285,13 +315,32 @@ public: // set operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template + iterator find(const K& x); + template + const_iterator find(const K& x) const; // C++14 + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template + iterator lower_bound(const K& x); // C++14 + template + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template + iterator upper_bound(const K& x); // C++14 + template + const_iterator upper_bound(const K& x) const; // C++14 + pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; + template + pair equal_range(const K& x); // C++14 + template + pair equal_range(const K& x) const; // C++14 }; template @@ -346,7 +395,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template , class _Allocator = allocator<_Key> > -class _LIBCPP_TYPE_VIS set +class _LIBCPP_TYPE_VIS_ONLY set { public: // types: @@ -403,6 +452,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : set(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set(const set& __s) : __tree_(__s.__tree_) @@ -455,6 +511,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + set(initializer_list __il, const allocator_type& __a) + : set(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set& operator=(initializer_list __il) { @@ -579,6 +641,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} @@ -588,18 +661,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) {return __tree_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} +#endif }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -685,7 +791,7 @@ swap(set<_Key, _Compare, _Allocator>& __x, template , class _Allocator = allocator<_Key> > -class _LIBCPP_TYPE_VIS multiset +class _LIBCPP_TYPE_VIS_ONLY multiset { public: // types: @@ -734,6 +840,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multiset(__f, __l, key_compare(), __a) {} +#endif + template _LIBCPP_INLINE_VISIBILITY multiset(_InputIterator __f, _InputIterator __l, @@ -793,6 +906,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multiset(initializer_list __il, const allocator_type& __a) + : multiset(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multiset& operator=(initializer_list __il) { @@ -917,27 +1036,72 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} + _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) {return __tree_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY pair equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} + template + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} +#endif }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/contrib/libc++/include/shared_mutex b/contrib/libc++/include/shared_mutex new file mode 100644 index 000000000..5b1f53aaf --- /dev/null +++ b/contrib/libc++/include/shared_mutex @@ -0,0 +1,419 @@ +// -*- C++ -*- +//===------------------------ shared_mutex --------------------------------===// +// +// 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_SHARED_MUTEX +#define _LIBCPP_SHARED_MUTEX + +/* + shared_mutex synopsis + +// C++1y + +namespace std +{ + +class shared_mutex +{ +public: + shared_mutex(); + ~shared_mutex(); + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + template + bool try_lock_for(const chrono::duration& rel_time); + template + bool try_lock_until(const chrono::time_point& abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + template + bool + try_lock_shared_for(const chrono::duration& rel_time); + template + bool + try_lock_shared_until(const chrono::time_point& abs_time); + void unlock_shared(); +}; + +template +class shared_lock +{ +public: + typedef Mutex mutex_type; + + // Shared locking + shared_lock() noexcept; + explicit shared_lock(mutex_type& m); // blocking + shared_lock(mutex_type& m, defer_lock_t) noexcept; + shared_lock(mutex_type& m, try_to_lock_t); + shared_lock(mutex_type& m, adopt_lock_t); + template + shared_lock(mutex_type& m, + const chrono::time_point& abs_time); + template + shared_lock(mutex_type& m, + const chrono::duration& rel_time); + ~shared_lock(); + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + shared_lock(shared_lock&& u) noexcept; + shared_lock& operator=(shared_lock&& u) noexcept; + + void lock(); // blocking + bool try_lock(); + template + bool try_lock_for(const chrono::duration& rel_time); + template + bool try_lock_until(const chrono::time_point& abs_time); + void unlock(); + + // Setters + void swap(shared_lock& u) noexcept; + mutex_type* release() noexcept; + + // Getters + bool owns_lock() const noexcept; + explicit operator bool () const noexcept; + mutex_type* mutex() const noexcept; +}; + +template + void swap(shared_lock& x, shared_lock& y) noexcept; + +} // std + +*/ + +#include <__config> + +#if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX) + +#include <__mutex_base> + +#include <__undef_min_max> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_TYPE_VIS shared_mutex +{ + mutex __mut_; + condition_variable __gate1_; + condition_variable __gate2_; + unsigned __state_; + + 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_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); + bool try_lock(); + template + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_until(chrono::steady_clock::now() + __rel_time); + } + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); + bool try_lock_shared(); + template + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_shared_until(chrono::steady_clock::now() + __rel_time); + } + template + bool + try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock_shared(); +}; + +template +bool +shared_mutex::try_lock_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock __lk(__mut_); + if (__state_ & __write_entered_) + { + while (true) + { + cv_status __status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0) + break; + if (__status == cv_status::timeout) + return false; + } + } + __state_ |= __write_entered_; + if (__state_ & __n_readers_) + { + while (true) + { + cv_status __status = __gate2_.wait_until(__lk, __abs_time); + if ((__state_ & __n_readers_) == 0) + break; + if (__status == cv_status::timeout) + { + __state_ &= ~__write_entered_; + return false; + } + } + } + return true; +} + +template +bool +shared_mutex::try_lock_shared_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock __lk(__mut_); + if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + { + while (true) + { + cv_status status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0 && + (__state_ & __n_readers_) < __n_readers_) + break; + if (status == cv_status::timeout) + return false; + } + } + unsigned __num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= __num_readers; + return true; +} + +template +class shared_lock +{ +public: + typedef _Mutex mutex_type; + +private: + mutex_type* __m_; + bool __owns_; + +public: + _LIBCPP_INLINE_VISIBILITY + shared_lock() noexcept + : __m_(nullptr), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit shared_lock(mutex_type& __m) + : __m_(&__m), + __owns_(true) + {__m_->lock_shared();} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, defer_lock_t) noexcept + : __m_(&__m), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, try_to_lock_t) + : __m_(&__m), + __owns_(__m.try_lock_shared()) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, adopt_lock_t) + : __m_(&__m), + __owns_(true) + {} + + template + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __abs_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_until(__abs_time)) + {} + + template + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rel_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_for(__rel_time)) + {} + + _LIBCPP_INLINE_VISIBILITY + ~shared_lock() + { + if (__owns_) + __m_->unlock_shared(); + } + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + _LIBCPP_INLINE_VISIBILITY + shared_lock(shared_lock&& __u) noexcept + : __m_(__u.__m_), + __owns_(__u.__owns_) + { + __u.__m_ = nullptr; + __u.__owns_ = false; + } + + _LIBCPP_INLINE_VISIBILITY + shared_lock& operator=(shared_lock&& __u) noexcept + { + if (__owns_) + __m_->unlock_shared(); + __m_ = nullptr; + __owns_ = false; + __m_ = __u.__m_; + __owns_ = __u.__owns_; + __u.__m_ = nullptr; + __u.__owns_ = false; + return *this; + } + + void lock(); + bool try_lock(); + template + bool try_lock_for(const chrono::duration& rel_time); + template + bool try_lock_until(const chrono::time_point& abs_time); + void unlock(); + + // Setters + _LIBCPP_INLINE_VISIBILITY + 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* __m = __m_; + __m_ = nullptr; + __owns_ = false; + return __m; + } + + // Getters + _LIBCPP_INLINE_VISIBILITY + bool owns_lock() const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + explicit operator bool () const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + mutex_type* mutex() const noexcept {return __m_;} +}; + +template +void +shared_lock<_Mutex>::lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::lock: already locked"); + __m_->lock_shared(); + __owns_ = true; +} + +template +bool +shared_lock<_Mutex>::try_lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked"); + __owns_ = __m_->try_lock_shared(); + return __owns_; +} + +template +template +bool +shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked"); + __owns_ = __m_->try_lock_shared_for(__d); + return __owns_; +} + +template +template +bool +shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked"); + __owns_ = __m_->try_lock_shared_until(__t); + return __owns_; +} + +template +void +shared_lock<_Mutex>::unlock() +{ + if (!__owns_) + __throw_system_error(EPERM, "shared_lock::unlock: not locked"); + __m_->unlock_shared(); + __owns_ = false; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept + {__x.swap(__y);} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_SHARED_MUTEX diff --git a/contrib/libc++/include/sstream b/contrib/libc++/include/sstream index a8f8148ad..f90d4464a 100644 --- a/contrib/libc++/include/sstream +++ b/contrib/libc++/include/sstream @@ -186,7 +186,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // basic_stringbuf template -class _LIBCPP_TYPE_VIS basic_stringbuf +class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: @@ -613,7 +613,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, // basic_istringstream template -class _LIBCPP_TYPE_VIS basic_istringstream +class _LIBCPP_TYPE_VIS_ONLY basic_istringstream : public basic_istream<_CharT, _Traits> { public: @@ -732,7 +732,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_ostringstream template -class _LIBCPP_TYPE_VIS basic_ostringstream +class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: @@ -851,7 +851,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_stringstream template -class _LIBCPP_TYPE_VIS basic_stringstream +class _LIBCPP_TYPE_VIS_ONLY basic_stringstream : public basic_iostream<_CharT, _Traits> { public: diff --git a/contrib/libc++/include/stack b/contrib/libc++/include/stack index b8a7f4c08..30909c1ee 100644 --- a/contrib/libc++/include/stack +++ b/contrib/libc++/include/stack @@ -91,7 +91,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS stack; +template class _LIBCPP_TYPE_VIS_ONLY stack; template _LIBCPP_INLINE_VISIBILITY @@ -104,7 +104,7 @@ bool operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); template > -class _LIBCPP_TYPE_VIS stack +class _LIBCPP_TYPE_VIS_ONLY stack { public: typedef _Container container_type; @@ -282,7 +282,7 @@ swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) } template -struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : public uses_allocator<_Container, _Alloc> { }; diff --git a/contrib/libc++/include/streambuf b/contrib/libc++/include/streambuf index 826159420..6adfc9237 100644 --- a/contrib/libc++/include/streambuf +++ b/contrib/libc++/include/streambuf @@ -119,7 +119,7 @@ protected: _LIBCPP_BEGIN_NAMESPACE_STD template -class _LIBCPP_TYPE_VIS basic_streambuf +class _LIBCPP_TYPE_VIS_ONLY basic_streambuf { public: // types: @@ -553,11 +553,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type) return traits_type::eof(); } -_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf) -_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf) -_LIBCPP_EXTERN_TEMPLATE(class basic_ios) -_LIBCPP_EXTERN_TEMPLATE(class basic_ios) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index 89f75cd2e..e8bd69fca 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -422,6 +422,11 @@ template <> struct hash; template <> struct hash; template <> struct hash; +basic_string operator "" s( const char *str, size_t len ); // C++14 +basic_string operator "" s( const wchar_t *str, size_t len ); // C++14 +basic_string operator "" s( const char16_t *str, size_t len ); // C++14 +basic_string operator "" s( const char32_t *str, size_t len ); // C++14 + } // std */ @@ -442,7 +447,7 @@ template <> struct hash; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS #include #endif -#if defined(_LIBCPP_NO_EXCEPTIONS) || defined(_LIBCPP_DEBUG) +#if defined(_LIBCPP_NO_EXCEPTIONS) #include #endif @@ -457,7 +462,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // fpos template -class _LIBCPP_TYPE_VIS fpos +class _LIBCPP_TYPE_VIS_ONLY fpos { private: _StateT __st_; @@ -494,7 +499,7 @@ bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) // char_traits template -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef _CharT char_type; typedef int int_type; @@ -600,6 +605,7 @@ inline _LIBCPP_INLINE_VISIBILITY _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -620,7 +626,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) // char_traits template <> -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef char char_type; typedef int int_type; @@ -651,7 +657,10 @@ struct _LIBCPP_TYPE_VIS char_traits {return (char_type*)memmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memcpy(__s1, __s2, __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) {return (char_type*)memset(__s, to_int_type(__a), __n);} @@ -676,7 +685,7 @@ struct _LIBCPP_TYPE_VIS char_traits // char_traits template <> -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef wchar_t char_type; typedef wint_t int_type; @@ -708,7 +717,10 @@ struct _LIBCPP_TYPE_VIS char_traits {return (char_type*)wmemmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemcpy(__s1, __s2, __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) {return (char_type*)wmemset(__s, __a, __n);} @@ -733,7 +745,7 @@ struct _LIBCPP_TYPE_VIS char_traits #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef char16_t char_type; typedef uint_least16_t int_type; @@ -836,6 +848,7 @@ inline _LIBCPP_INLINE_VISIBILITY char16_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -853,7 +866,7 @@ char_traits::assign(char_type* __s, size_t __n, char_type __a) } template <> -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef char32_t char_type; typedef uint_least32_t int_type; @@ -956,6 +969,7 @@ inline _LIBCPP_INLINE_VISIBILITY char32_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -998,7 +1012,7 @@ basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); template -class __basic_string_common +class _LIBCPP_TYPE_VIS_ONLY __basic_string_common { protected: void __throw_length_error() const; @@ -1027,14 +1041,14 @@ __basic_string_common<__b>::__throw_out_of_range() const #endif } -#ifdef _MSC_VER +#ifdef _LIBCPP_MSVC #pragma warning( push ) #pragma warning( disable: 4231 ) -#endif // _MSC_VER -_LIBCPP_EXTERN_TEMPLATE(class __basic_string_common) -#ifdef _MSC_VER +#endif // _LIBCPP_MSVC +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common) +#ifdef _LIBCPP_MSVC #pragma warning( pop ) -#endif // _MSC_VER +#endif // _LIBCPP_MSVC #ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT @@ -1052,7 +1066,7 @@ struct __padding<_CharT, 1> #endif // _LIBCPP_ALTERNATE_STRING_LAYOUT template -class _LIBCPP_TYPE_VIS basic_string +class _LIBCPP_TYPE_VIS_ONLY basic_string : private __basic_string_common { public: @@ -1067,13 +1081,13 @@ public: typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter iterator; - typedef __debug_iter const_iterator; - friend class __debug_iter; - friend class __debug_iter; -#elif defined(_LIBCPP_RAW_ITERATORS) + static_assert(is_pod::value, "Character type of basic_string must be a POD"); + static_assert((is_same<_CharT, value_type>::value), + "traits_type::char_type must be the same type as CharT"); + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); +#if defined(_LIBCPP_RAW_ITERATORS) typedef pointer iterator; typedef const_pointer const_iterator; #else // defined(_LIBCPP_RAW_ITERATORS) @@ -1147,9 +1161,9 @@ private: #endif // _LIBCPP_ALTERNATE_STRING_LAYOUT - union __lx{__long __lx; __short __lxx;}; + union __ulx{__long __lx; __short __lxx;}; - enum {__n_words = sizeof(__lx) / sizeof(size_type)}; + enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; struct __raw { @@ -1168,15 +1182,6 @@ private: __compressed_pair<__rep, allocator_type> __r_; -#ifdef _LIBCPP_DEBUG - - pair __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} - -#endif // _LIBCPP_DEBUG - public: static const size_type npos = -1; @@ -1234,7 +1239,20 @@ public: basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#ifndef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + iterator begin() _NOEXCEPT + {return iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + const_iterator begin() const _NOEXCEPT + {return const_iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + iterator end() _NOEXCEPT + {return iterator(this, __get_pointer() + size());} + _LIBCPP_INLINE_VISIBILITY + const_iterator end() const _NOEXCEPT + {return const_iterator(this, __get_pointer() + size());} +#else _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__get_pointer());} @@ -1247,12 +1265,7 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__get_pointer() + size());} -#else // _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(this, __get_pointer());} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return const_iterator(this, data());} - _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(this, __get_pointer() + size());} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const {return const_iterator(this, data() + size());} -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} @@ -1515,6 +1528,15 @@ public: bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);} +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const; + bool __decrementable(const const_iterator* __i) const; + bool __addable(const const_iterator* __i, ptrdiff_t __n) const; + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT @@ -1610,13 +1632,13 @@ private: template static _LIBCPP_INLINE_VISIBILITY - size_type __align(size_type __s) _NOEXCEPT + size_type __align_it(size_type __s) _NOEXCEPT {return __s + (__a-1) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT {return (__s < __min_cap ? __min_cap : - __align (__s+1)) - 1;} void __init(const value_type* __s, size_type __sz, size_type __reserve); @@ -1727,75 +1749,64 @@ private: }; template -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__invalidate_all(this); +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type -#ifdef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 __pos #endif ) { -#ifdef _LIBCPP_DEBUG - const_iterator __beg = begin(); - if (__iterator_list_.first) +#if _LIBCPP_DEBUG_LEVEL >= 2 + __c_node* __c = __get_db()->__find_c_and_lock(this); + if (__c) { - for (iterator* __p = __iterator_list_.first; __p;) + const_pointer __new_last = __get_pointer() + __pos; + for (__i_node** __p = __c->end_; __p != __c->beg_; ) { - if (*__p - __beg > static_cast(__pos)) + --__p; + const_iterator* __i = static_cast((*__p)->__i_); + if (__i->base() > __new_last) { - iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } - else - __p = __p->__next; } + __get_db()->unlock(); } - if (__iterator_list_.second) - { - for (const_iterator* __p = __iterator_list_.second; __p;) - { - if (*__p - __beg > static_cast(__pos)) - { - const_iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); - } - else - __p = __p->__next; - } - } -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) : __r_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } @@ -1848,45 +1859,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -1897,6 +1912,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -1907,24 +1925,29 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) _NOEXCEPT_(is_nothrow_move_constructible::value) : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__a) { @@ -1933,8 +1956,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } @@ -1965,18 +1990,24 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c, const allocator_type& __a) : __r_(__a) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -1988,6 +2019,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st if (__pos > __str_sz) this->__throw_out_of_range(); __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -2051,37 +2085,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For template template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__a) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list __il) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list __il, const allocator_type& __a) : __r_(__a) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2089,7 +2135,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list basic_string<_CharT, _Traits, _Allocator>::~basic_string() { - __invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__erase_c(this); +#endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } @@ -2133,7 +2181,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t size_type __n_copy, size_type __n_del, size_type __n_add) { size_type __ms = max_size(); - if (__delta_cap > __ms - __old_cap - 1) + if (__delta_cap > __ms - __old_cap) this->__throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? @@ -2161,9 +2209,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr"); size_type __cap = capacity(); if (__cap >= __n) { @@ -2236,7 +2282,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) { @@ -2247,7 +2293,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) @@ -2260,7 +2306,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -2316,7 +2362,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str) { @@ -2337,9 +2383,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr"); return assign(__s, traits_type::length(__s)); } @@ -2349,9 +2393,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) @@ -2467,7 +2509,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) { @@ -2488,9 +2530,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr"); return append(__s, traits_type::length(__s)); } @@ -2500,9 +2540,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2571,13 +2609,22 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __old_sz = size(); difference_type __ip = __pos - begin(); for (; __first != __last; ++__first) push_back(*__first); pointer __p = __get_pointer(); _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(this, __p + __ip); +#else return iterator(__p + __ip); +#endif } template @@ -2589,6 +2636,11 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __ip = static_cast(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); @@ -2618,7 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) { @@ -2640,9 +2692,7 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr"); return insert(__pos, __s, traits_type::length(__s)); } @@ -2673,10 +2723,15 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, n, value) called with an iterator not" + " referring to this string"); +#endif difference_type __p = __pos - begin(); insert(static_cast(__p), __n, __c); return begin() + __p; @@ -2688,9 +2743,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) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2800,7 +2853,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) { @@ -2822,14 +2875,12 @@ template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) { @@ -2838,7 +2889,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) { @@ -2846,7 +2897,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) { @@ -2854,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) { @@ -2886,10 +2937,17 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::erase(iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__pos != end(), + "string::erase(iterator) called with a non-dereferenceable iterator"); iterator __b = begin(); size_type __r = static_cast(__pos - __b); erase(__r, 1); @@ -2897,10 +2955,16 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, + "string::erase(iterator, iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); iterator __b = begin(); size_type __r = static_cast(__first - __b); erase(__r, static_cast(__last - __first)); @@ -2908,13 +2972,11 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::pop_back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); size_type __sz; if (__is_long()) { @@ -2932,7 +2994,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back() } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { @@ -2950,7 +3012,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) { @@ -2979,15 +3041,15 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT { size_type __m = __alloc_traits::max_size(__alloc()); #if _LIBCPP_BIG_ENDIAN - return (__m <= ~__long_mask ? __m : __m/2) - 1; + return (__m <= ~__long_mask ? __m : __m/2) - __alignment; #else - return __m - 1; + return __m - __alignment; #endif } @@ -3055,24 +3117,20 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const { -#ifdef __LIBCPP_DEBUG - assert(__pos <= size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(data() + __pos); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) { -#ifdef __LIBCPP_DEBUG - assert(__pos < size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(__get_pointer() + __pos); } @@ -3095,46 +3153,38 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::front() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *__get_pointer(); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::front() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *data(); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(__get_pointer() + size() - 1); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::back() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(data() + size() - 1); } @@ -3151,7 +3201,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const { @@ -3159,18 +3209,21 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + if (!__is_long()) + __get_db()->__invalidate_all(this); + if (!__str.__is_long()) + __get_db()->__invalidate_all(&__str); + __get_db()->swap(this, &__str); +#endif _VSTD::swap(__r_.first(), __str.__r_.first()); __swap_alloc(__alloc(), __str.__alloc()); -#ifdef _LIBCPP_DEBUG - __invalidate_all_iterators(); - __str.__invalidate_all_iterators(); -#endif // _LIBCPP_DEBUG } // find @@ -3190,9 +3243,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr"); size_type __sz = size(); if (__pos > __sz || __sz - __pos < __n) return npos; @@ -3207,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3216,14 +3267,12 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr"); return find(__s, __pos, traits_type::length(__s)); } @@ -3250,9 +3299,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr"); size_type __sz = size(); __pos = _VSTD::min(__pos, __sz); if (__n < __sz - __pos) @@ -3268,7 +3315,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3277,14 +3324,12 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr"); return rfind(__s, __pos, traits_type::length(__s)); } @@ -3318,9 +3363,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr"); size_type __sz = size(); if (__pos >= __sz || __n == 0) return npos; @@ -3333,7 +3376,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3342,19 +3385,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr"); return find_first_of(__s, __pos, traits_type::length(__s)); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3370,9 +3411,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr"); if (__n != 0) { size_type __sz = size(); @@ -3392,7 +3431,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3401,19 +3440,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr"); return find_last_of(__s, __pos, traits_type::length(__s)); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3429,9 +3466,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) { @@ -3445,7 +3480,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3454,19 +3489,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr"); return find_first_not_of(__s, __pos, traits_type::length(__s)); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3491,9 +3524,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) ++__pos; @@ -3507,7 +3538,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3516,19 +3547,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr"); return find_last_not_of(__s, __pos, traits_type::length(__s)); } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY 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 @@ -3548,7 +3577,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, // compare template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { @@ -3566,7 +3595,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, @@ -3594,9 +3623,7 @@ template int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(0, npos, __s, traits_type::length(__s)); } @@ -3606,9 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); } @@ -3619,9 +3644,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, const value_type* __s, size_type __n2) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) this->__throw_out_of_range(); @@ -3640,7 +3663,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, // __invariants template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const { @@ -3658,7 +3681,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const // operator== template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3670,7 +3693,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string, _Allocator>& __lhs, const basic_string, _Allocator>& __rhs) _NOEXCEPT @@ -3689,7 +3712,7 @@ operator==(const basic_string, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3698,7 +3721,7 @@ operator==(const _CharT* __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3709,7 +3732,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, // operator!= template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3718,7 +3741,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3727,7 +3750,7 @@ operator!=(const _CharT* __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3738,7 +3761,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, // operator< template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3747,7 +3770,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3756,7 +3779,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3767,7 +3790,7 @@ operator< (const _CharT* __lhs, // operator> template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3776,7 +3799,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3785,7 +3808,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3796,7 +3819,7 @@ operator> (const _CharT* __lhs, // operator<= template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3805,7 +3828,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3814,7 +3837,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3825,7 +3848,7 @@ operator<=(const _CharT* __lhs, // operator>= template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3834,7 +3857,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3843,7 +3866,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3915,7 +3938,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { @@ -3923,7 +3946,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string< } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3931,7 +3954,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3939,7 +3962,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3947,7 +3970,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3956,7 +3979,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { @@ -3964,7 +3987,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { @@ -3977,7 +4000,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) // swap template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) @@ -3993,45 +4016,45 @@ typedef basic_string u32string; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS -int stoi (const string& __str, size_t* __idx = 0, int __base = 10); -long stol (const string& __str, size_t* __idx = 0, int __base = 10); -unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); -long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); -unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); - -float stof (const string& __str, size_t* __idx = 0); -double stod (const string& __str, size_t* __idx = 0); -long double stold(const string& __str, size_t* __idx = 0); - -string to_string(int __val); -string to_string(unsigned __val); -string to_string(long __val); -string to_string(unsigned long __val); -string to_string(long long __val); -string to_string(unsigned long long __val); -string to_string(float __val); -string to_string(double __val); -string to_string(long double __val); - -int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); -long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); -unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); -long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); -unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); - -float stof (const wstring& __str, size_t* __idx = 0); -double stod (const wstring& __str, size_t* __idx = 0); -long double stold(const wstring& __str, size_t* __idx = 0); - -wstring to_wstring(int __val); -wstring to_wstring(unsigned __val); -wstring to_wstring(long __val); -wstring to_wstring(unsigned long __val); -wstring to_wstring(long long __val); -wstring to_wstring(unsigned long long __val); -wstring to_wstring(float __val); -wstring to_wstring(double __val); -wstring to_wstring(long double __val); +_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); + +_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0); + +_LIBCPP_FUNC_VIS string to_string(int __val); +_LIBCPP_FUNC_VIS string to_string(unsigned __val); +_LIBCPP_FUNC_VIS string to_string(long __val); +_LIBCPP_FUNC_VIS string to_string(unsigned long __val); +_LIBCPP_FUNC_VIS string to_string(long long __val); +_LIBCPP_FUNC_VIS string to_string(unsigned long long __val); +_LIBCPP_FUNC_VIS string to_string(float __val); +_LIBCPP_FUNC_VIS string to_string(double __val); +_LIBCPP_FUNC_VIS string to_string(long double __val); + +_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); + +_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0); + +_LIBCPP_FUNC_VIS wstring to_wstring(int __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(float __val); +_LIBCPP_FUNC_VIS wstring to_wstring(double __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long double __val); template const typename basic_string<_CharT, _Traits, _Allocator>::size_type @@ -4045,7 +4068,7 @@ size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) } template -struct _LIBCPP_TYPE_VIS hash > +struct _LIBCPP_TYPE_VIS_ONLY hash > : public unary_function, size_t> { size_t @@ -4097,12 +4120,78 @@ getline(basic_istream<_CharT, _Traits>&& __is, #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -_LIBCPP_EXTERN_TEMPLATE(class basic_string) -_LIBCPP_EXTERN_TEMPLATE(class basic_string) +#if _LIBCPP_DEBUG_LEVEL >= 2 + +template +bool +basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const +{ + return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); +} + +template +bool +basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const +{ + return this->data() < _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); +} + +template +bool +basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p <= this->data() + this->size(); +} + +template +bool +basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p < this->data() + this->size(); +} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + +#if _LIBCPP_STD_VER > 11 +// Literal suffixes for basic_string [basic.string.literals] +inline namespace literals +{ + inline namespace string_literals + { + inline _LIBCPP_INLINE_VISIBILITY + basic_string operator "" s( const char *__str, size_t __len ) + { + return basic_string (__str, __len); + } + + inline _LIBCPP_INLINE_VISIBILITY + basic_string operator "" s( const wchar_t *__str, size_t __len ) + { + return basic_string (__str, __len); + } + + inline _LIBCPP_INLINE_VISIBILITY + basic_string operator "" s( const char16_t *__str, size_t __len ) + { + return basic_string (__str, __len); + } + + inline _LIBCPP_INLINE_VISIBILITY + basic_string operator "" s( const char32_t *__str, size_t __len ) + { + return basic_string (__str, __len); + } + } +} +#endif -extern template - string - operator+, allocator >(char const*, string const&); +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string) +_LIBCPP_EXTERN_TEMPLATE(string operator+, allocator >(char const*, string const&)) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/system_error b/contrib/libc++/include/system_error index 1c1c7ebdd..66bf6d6c4 100644 --- a/contrib/libc++/include/system_error +++ b/contrib/libc++/include/system_error @@ -22,6 +22,7 @@ class error_category public: virtual ~error_category() noexcept; + constexpr error_category(); error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; @@ -232,13 +233,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD // is_error_code_enum template -struct _LIBCPP_TYPE_VIS is_error_code_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public false_type {}; // is_error_condition_enum template -struct _LIBCPP_TYPE_VIS is_error_condition_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum : public false_type {}; // Some error codes are not present on all platforms, so we provide equivalents @@ -345,12 +346,12 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc) template <> -struct _LIBCPP_TYPE_VIS is_error_condition_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum : true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_condition_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum : true_type { }; #endif @@ -366,7 +367,12 @@ class _LIBCPP_TYPE_VIS error_category public: virtual ~error_category() _NOEXCEPT; +#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR error_category() _NOEXCEPT; +#else + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT; +#endif private: error_category(const error_category&);// = delete; error_category& operator=(const error_category&);// = delete; @@ -397,8 +403,8 @@ public: virtual string message(int ev) const; }; -const error_category& generic_category() _NOEXCEPT; -const error_category& system_category() _NOEXCEPT; +_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; +_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; class _LIBCPP_TYPE_VIS error_condition { @@ -597,7 +603,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT {return !(__x == __y);} template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY @@ -629,7 +635,7 @@ private: static string __init(const error_code&, string); }; -void __throw_system_error(int ev, const char* what_arg); +_LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/thread b/contrib/libc++/include/thread index f41ea2902..1f1e4a2b9 100644 --- a/contrib/libc++/include/thread +++ b/contrib/libc++/include/thread @@ -185,10 +185,9 @@ _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT; } // this_thread -class _LIBCPP_TYPE_VIS __thread_id; -template<> struct _LIBCPP_TYPE_VIS hash<__thread_id>; +template<> struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>; -class _LIBCPP_TYPE_VIS __thread_id +class _LIBCPP_TYPE_VIS_ONLY __thread_id { // FIXME: pthread_t is a pointer on Darwin but a long on Linux. // NULL is the no-thread value on Darwin. Someone needs to check @@ -231,11 +230,11 @@ private: friend __thread_id this_thread::get_id() _NOEXCEPT; friend class _LIBCPP_TYPE_VIS thread; - friend struct _LIBCPP_TYPE_VIS hash<__thread_id>; + friend struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>; }; template<> -struct _LIBCPP_TYPE_VIS hash<__thread_id> +struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id> : public unary_function<__thread_id, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -307,7 +306,7 @@ class __assoc_sub_state; class _LIBCPP_HIDDEN __thread_struct_imp; -class __thread_struct +class _LIBCPP_TYPE_VIS __thread_struct { __thread_struct_imp* __p_; @@ -321,7 +320,7 @@ public: void __make_ready_at_thread_exit(__assoc_sub_state*); }; -__thread_specific_ptr<__thread_struct>& __thread_local_data(); +_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -405,7 +404,7 @@ void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);} namespace this_thread { -void sleep_for(const chrono::nanoseconds& ns); +_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& ns); template void diff --git a/contrib/libc++/include/tuple b/contrib/libc++/include/tuple index 0df315e2a..a1a7bcf0b 100644 --- a/contrib/libc++/include/tuple +++ b/contrib/libc++/include/tuple @@ -21,19 +21,19 @@ template class tuple { public: constexpr tuple(); - explicit tuple(const T&...); + explicit tuple(const T&...); // constexpr in C++14 template - explicit tuple(U&&...); + explicit tuple(U&&...); // constexpr in C++14 tuple(const tuple&) = default; tuple(tuple&&) = default; template - tuple(const tuple&); + tuple(const tuple&); // constexpr in C++14 template - tuple(tuple&&); + tuple(tuple&&); // constexpr in C++14 template - tuple(const pair&); // iff sizeof...(T) == 2 + tuple(const pair&); // iff sizeof...(T) == 2 // constexpr in C++14 template - tuple(pair&&); // iff sizeof...(T) == 2 + tuple(pair&&); // iff sizeof...(T) == 2 // constexpr in C++14 // allocator-extended constructors template @@ -72,10 +72,10 @@ public: const unspecified ignore; -template tuple make_tuple(T&&...); -template tuple forward_as_tuple(T&&...) noexcept; +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 tuple_cat(Tuples&&... tpls); +template tuple tuple_cat(Tuples&&... tpls); // constexpr in C++14 // 20.4.1.4, tuple helper classes: template class tuple_size; // undefined @@ -86,21 +86,28 @@ template class tuple_element>; // 20.4.1.5, element access: template typename tuple_element>::type& - get(tuple&) noexcept; + get(tuple&) noexcept; // constexpr in C++14 template typename tuple_element>::type const& - get(const tuple&) noexcept; + get(const tuple&) noexcept; // constexpr in C++14 template typename tuple_element>::type&& - get(tuple&&) noexcept; + get(tuple&&) noexcept; // constexpr in C++14 + +template + constexpr T1& get(tuple&) noexcept; // C++14 +template + constexpr T1 const& get(const tuple&) noexcept; // C++14 +template + constexpr T1&& get(tuple&&) noexcept; // C++14 // 20.4.1.6, relational operators: -template bool operator==(const tuple&, const tuple&); -template bool operator<(const tuple&, const tuple&); -template bool operator!=(const tuple&, const tuple&); -template bool operator>(const tuple&, const tuple&); -template bool operator<=(const tuple&, const tuple&); -template bool operator>=(const tuple&, const tuple&); +template bool operator==(const tuple&, const tuple&); // constexpr in C++14 +template bool operator<(const tuple&, const tuple&); // constexpr in C++14 +template bool operator!=(const tuple&, const tuple&); // constexpr in C++14 +template bool operator>(const tuple&, const tuple&); // constexpr in C++14 +template bool operator<=(const tuple&, const tuple&); // constexpr in C++14 +template bool operator>=(const tuple&, const tuple&); // constexpr in C++14 template struct uses_allocator, Alloc>; @@ -126,74 +133,12 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -// allocator_arg_t - -struct _LIBCPP_TYPE_VIS allocator_arg_t { }; - -#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) -extern const allocator_arg_t allocator_arg; -#else -constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template ::value> -struct __uses_allocator - : public integral_constant::value> -{ -}; - -template -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template -struct _LIBCPP_TYPE_VIS uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#ifndef _LIBCPP_HAS_NO_VARIADICS - -// uses-allocator construction - -template -struct __uses_alloc_ctor_imp -{ - static const bool __ua = uses_allocator<_Tp, _Alloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template -struct __uses_alloc_ctor - : integral_constant::value> - {}; - -#endif // _LIBCPP_HAS_NO_VARIADICS - #ifndef _LIBCPP_HAS_NO_VARIADICS // tuple_size template -class _LIBCPP_TYPE_VIS tuple_size > +class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant { }; @@ -201,7 +146,7 @@ class _LIBCPP_TYPE_VIS tuple_size > // tuple_element template -class _LIBCPP_TYPE_VIS tuple_element<_Ip, tuple<_Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> > { public: typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; @@ -259,7 +204,7 @@ public: template ::value>::type> - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : value(_VSTD::forward<_Tp>(__t)) {static_assert(!is_reference<_Hp>::value || @@ -316,15 +261,17 @@ 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");} - template - _LIBCPP_INLINE_VISIBILITY - explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t) - _NOEXCEPT_((is_nothrow_constructible<_Hp, const _Tp&>::value)) - : value(__t.get()) {} + _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())) + {} template _LIBCPP_INLINE_VISIBILITY @@ -342,8 +289,8 @@ public: return 0; } - _LIBCPP_INLINE_VISIBILITY _Hp& get() _NOEXCEPT {return value;} - _LIBCPP_INLINE_VISIBILITY const _Hp& get() const _NOEXCEPT {return value;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;} }; template @@ -372,7 +319,7 @@ public: template ::value>::type> - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : _Hp(_VSTD::forward<_Tp>(__t)) {} @@ -391,12 +338,6 @@ public: explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : _Hp(_VSTD::forward<_Tp>(__t), __a) {} - template - _LIBCPP_INLINE_VISIBILITY - explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t) - _NOEXCEPT_((is_nothrow_constructible<_Hp, const _Tp&>::value)) - : _Hp(__t.get()) {} - template _LIBCPP_INLINE_VISIBILITY __tuple_leaf& @@ -414,8 +355,8 @@ public: return 0; } - _LIBCPP_INLINE_VISIBILITY _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} - _LIBCPP_INLINE_VISIBILITY const _Hp& get() const _NOEXCEPT {return static_cast(*this);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast(*this);} }; template @@ -450,7 +391,7 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>, __tuple_indices<_Ul...>, __tuple_types<_Tl...>, @@ -480,7 +421,7 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> __tuple_constructible<_Tuple, tuple<_Tp...> >::value >::type > - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all::type>::type>::value...>::value)) : __tuple_leaf<_Indx, _Tp>(_VSTD::forward, _Tp...> return *this; } - _LIBCPP_INLINE_VISIBILITY - __tuple_impl& - operator=(const __tuple_impl& __t) _NOEXCEPT_((__all::value...>::value)) - { - __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast&>(__t).get())...); - return *this; - } + __tuple_impl(const __tuple_impl&) = default; + __tuple_impl(__tuple_impl&&) = default; + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(const __tuple_impl& __t) _NOEXCEPT_((__all::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast&>(__t).get())...); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(__tuple_impl&& __t) _NOEXCEPT_((__all::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...); + return *this; + } _LIBCPP_INLINE_VISIBILITY void swap(__tuple_impl& __t) @@ -533,17 +485,17 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> }; template -class _LIBCPP_TYPE_VIS tuple +class _LIBCPP_TYPE_VIS_ONLY tuple { typedef __tuple_impl::type, _Tp...> base; base base_; - template friend + template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT; - template friend + template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT; - template friend + template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; public: @@ -551,7 +503,7 @@ public: _LIBCPP_CONSTEXPR tuple() _NOEXCEPT_(__all::value...>::value) {} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all::value...>::value)) : base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), @@ -586,7 +538,7 @@ public: bool >::type = false > - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(_Up&&... __u) _NOEXCEPT_(( is_nothrow_constructible< @@ -626,7 +578,7 @@ public: bool >::type =false > - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(_Up&&... __u) _NOEXCEPT_(( @@ -674,7 +626,7 @@ public: bool >::type = false > - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value)) : base_(_VSTD::forward<_Tuple>(__t)) {} @@ -686,7 +638,7 @@ public: bool >::type = false > - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value)) : base_(_VSTD::forward<_Tuple>(__t)) {} @@ -721,7 +673,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS tuple<> +class _LIBCPP_TYPE_VIS_ONLY tuple<> { public: _LIBCPP_INLINE_VISIBILITY @@ -756,7 +708,7 @@ swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) // get template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type& get(tuple<_Tp...>& __t) _NOEXCEPT { @@ -765,7 +717,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, tuple<_Tp...> >::type& get(const tuple<_Tp...>& __t) _NOEXCEPT { @@ -774,7 +726,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&& __t) _NOEXCEPT { @@ -783,6 +735,64 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get()); } +#if _LIBCPP_STD_VER > 11 +// get by type +template +struct __find_exactly_one_t_helper; + +// -- find exactly one +template +struct __find_exactly_one_t_checker { + static constexpr size_t value = _Idx; +// Check the rest of the list to make sure there's only one + static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" ); + }; + + +template +struct __find_exactly_one_t_helper <_T1, _Idx> { + static constexpr size_t value = -1; + }; + +template +struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> { + static constexpr size_t value = + std::conditional< + std::is_same<_T1, _Head>::value, + __find_exactly_one_t_checker<_T1, _Idx, _Args...>, + __find_exactly_one_t_helper <_T1, _Idx+1, _Args...> + >::type::value; + }; + +template +struct __find_exactly_one_t { + static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value; + static_assert ( value != -1, "type not found in type list" ); + }; + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1& get(tuple<_Args...>& __tup) noexcept +{ + return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept +{ + return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept +{ + return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); +} + +#endif + // tie template @@ -803,7 +813,7 @@ struct __ignore_t namespace { const __ignore_t ignore = __ignore_t(); } -template class _LIBCPP_TYPE_VIS reference_wrapper; +template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template struct ___make_tuple_return @@ -824,7 +834,7 @@ struct __make_tuple_return }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple::type...> make_tuple(_Tp&&... __t) { @@ -832,7 +842,7 @@ make_tuple(_Tp&&... __t) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT { @@ -843,7 +853,7 @@ template struct __tuple_equal { template - _LIBCPP_INLINE_VISIBILITY + _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); @@ -854,7 +864,7 @@ template <> struct __tuple_equal<0> { template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp&, const _Up&) { return true; @@ -862,7 +872,7 @@ struct __tuple_equal<0> }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -870,7 +880,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -881,7 +891,7 @@ template struct __tuple_less { template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { return __tuple_less<_Ip-1>()(__x, __y) || @@ -893,7 +903,7 @@ template <> struct __tuple_less<0> { template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp&, const _Up&) { return false; @@ -901,7 +911,7 @@ struct __tuple_less<0> }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -909,7 +919,7 @@ operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -917,7 +927,7 @@ operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -925,7 +935,7 @@ operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { @@ -983,7 +993,7 @@ struct __tuple_cat_return<> typedef tuple<> type; }; -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<> tuple_cat() { @@ -1030,16 +1040,16 @@ template struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J0...> > { template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return_ref&&, _Tuple0&&>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0) { - return _VSTD::forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., + return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); } template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return_ref&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) { @@ -1049,7 +1059,7 @@ struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>, typename __make_tuple_indices::value>::type, typename __make_tuple_indices::value>::type>() - (_VSTD::forward_as_tuple( + (forward_as_tuple( _VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))... ), @@ -1059,7 +1069,7 @@ struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return<_Tuple0, _Tuples...>::type tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { @@ -1071,7 +1081,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) } template -struct _LIBCPP_TYPE_VIS uses_allocator, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator, _Alloc> : true_type {}; template diff --git a/contrib/libc++/include/type_traits b/contrib/libc++/include/type_traits index a8730eca5..a97441d76 100644 --- a/contrib/libc++/include/type_traits +++ b/contrib/libc++/include/type_traits @@ -28,6 +28,7 @@ namespace std // Primary classification traits: template struct is_void; + template struct is_null_pointer; // C++14 template struct is_integral; template struct is_floating_point; template struct is_array; @@ -208,16 +209,16 @@ namespace std _LIBCPP_BEGIN_NAMESPACE_STD template - struct _LIBCPP_TYPE_VIS conditional {typedef _If type;}; + struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template - struct _LIBCPP_TYPE_VIS conditional {typedef _Then type;}; + struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _Then type;}; #if _LIBCPP_STD_VER > 11 template using conditional_t = typename conditional<_Bp, _If, _Then>::type; #endif -template struct _LIBCPP_TYPE_VIS enable_if {}; -template struct _LIBCPP_TYPE_VIS enable_if {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; +template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using enable_if_t = typename enable_if<_Bp, _Tp>::type; @@ -229,13 +230,17 @@ struct __two {char __lx[2];}; // helper class: template -struct _LIBCPP_TYPE_VIS integral_constant +struct _LIBCPP_TYPE_VIS_ONLY integral_constant { static _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator value_type() const {return value;} +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + constexpr value_type operator ()() const {return value;} +#endif }; template @@ -246,33 +251,33 @@ typedef integral_constant false_type; // is_const -template struct _LIBCPP_TYPE_VIS is_const : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_const<_Tp const> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; // is_volatile -template struct _LIBCPP_TYPE_VIS is_volatile : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_volatile<_Tp volatile> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; // remove_const -template struct _LIBCPP_TYPE_VIS remove_const {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_const {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_const_t = typename remove_const<_Tp>::type; #endif // remove_volatile -template struct _LIBCPP_TYPE_VIS remove_volatile {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_volatile {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_volatile_t = typename remove_volatile<_Tp>::type; #endif // remove_cv -template struct _LIBCPP_TYPE_VIS remove_cv +template struct _LIBCPP_TYPE_VIS_ONLY remove_cv {typedef typename remove_volatile::type>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_cv_t = typename remove_cv<_Tp>::type; @@ -283,7 +288,7 @@ template using remove_cv_t = typename remove_cv<_Tp>::type; template struct __libcpp_is_void : public false_type {}; template <> struct __libcpp_is_void : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_void +template struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void::type> {}; // __is_nullptr_t @@ -291,9 +296,14 @@ template struct _LIBCPP_TYPE_VIS is_void template struct __libcpp___is_nullptr : public false_type {}; template <> struct __libcpp___is_nullptr : public true_type {}; -template struct _LIBCPP_TYPE_VIS __is_nullptr_t +template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t : public __libcpp___is_nullptr::type> {}; +#if _LIBCPP_STD_VER > 11 +template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer + : public ____is_nullptr_t::type> {}; +#endif + // is_integral template struct __libcpp_is_integral : public false_type {}; @@ -315,7 +325,7 @@ 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_TYPE_VIS is_integral +template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; // is_floating_point @@ -325,16 +335,16 @@ template <> struct __libcpp_is_floating_point : public tru template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_floating_point +template struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point::type> {}; // is_array -template struct _LIBCPP_TYPE_VIS is_array +template struct _LIBCPP_TYPE_VIS_ONLY is_array : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_array<_Tp[]> +template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]> +template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; // is_pointer @@ -342,23 +352,23 @@ template struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]> template struct __libcpp_is_pointer : public false_type {}; template struct __libcpp_is_pointer<_Tp*> : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_pointer +template struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer::type> {}; // is_reference -template struct _LIBCPP_TYPE_VIS is_lvalue_reference : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_lvalue_reference<_Tp&> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_rvalue_reference : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template struct _LIBCPP_TYPE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; #endif -template struct _LIBCPP_TYPE_VIS is_reference : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_reference<_Tp&> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) @@ -369,13 +379,13 @@ template struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_t #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS is_union +template struct _LIBCPP_TYPE_VIS_ONLY is_union : public integral_constant {}; #else template struct __libcpp_union : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_union +template struct _LIBCPP_TYPE_VIS_ONLY is_union : public __libcpp_union::type> {}; #endif @@ -384,7 +394,7 @@ template struct _LIBCPP_TYPE_VIS is_union #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS is_class +template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant {}; #else @@ -395,15 +405,15 @@ template char __test(int _Tp::*); template __two __test(...); } -template struct _LIBCPP_TYPE_VIS is_class +template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; #endif // is_same -template struct _LIBCPP_TYPE_VIS is_same : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_same<_Tp, _Tp> : public true_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; // is_function @@ -418,13 +428,13 @@ template ::value || is_union<_Tp>::value || is_void<_Tp>::value || is_reference<_Tp>::value || - is_same<_Tp, nullptr_t>::value > + __is_nullptr_t<_Tp>::value > struct __libcpp_is_function : public integral_constant(__is_function_imp::__source<_Tp>())) == 1> {}; template struct __libcpp_is_function<_Tp, true> : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_function +template struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; // is_member_function_pointer @@ -432,7 +442,7 @@ template struct _LIBCPP_TYPE_VIS is_function template struct __libcpp_is_member_function_pointer : public false_type {}; template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; -template struct _LIBCPP_TYPE_VIS is_member_function_pointer +template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type> {}; // is_member_pointer @@ -440,12 +450,12 @@ template struct _LIBCPP_TYPE_VIS is_member_function_pointer template struct __libcpp_is_member_pointer : public false_type {}; template struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_member_pointer +template struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer::type> {}; // is_member_object_pointer -template struct _LIBCPP_TYPE_VIS is_member_object_pointer +template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant::value && !is_member_function_pointer<_Tp>::value> {}; @@ -453,12 +463,12 @@ template struct _LIBCPP_TYPE_VIS is_member_object_pointer #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS is_enum +template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant {}; #else -template struct _LIBCPP_TYPE_VIS is_enum +template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant::value && !is_integral<_Tp>::value && !is_floating_point<_Tp>::value && @@ -474,31 +484,31 @@ template struct _LIBCPP_TYPE_VIS is_enum // is_arithmetic -template struct _LIBCPP_TYPE_VIS is_arithmetic +template struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; // is_fundamental -template struct _LIBCPP_TYPE_VIS is_fundamental +template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental : public integral_constant::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; // is_scalar -template struct _LIBCPP_TYPE_VIS is_scalar +template struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public integral_constant::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || __is_nullptr_t<_Tp>::value || is_enum<_Tp>::value > {}; -template <> struct _LIBCPP_TYPE_VIS is_scalar : public true_type {}; +template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public true_type {}; // is_object -template struct _LIBCPP_TYPE_VIS is_object +template struct _LIBCPP_TYPE_VIS_ONLY is_object : public integral_constant::value || is_array<_Tp>::value || is_union<_Tp>::value || @@ -506,7 +516,7 @@ template struct _LIBCPP_TYPE_VIS is_object // is_compound -template struct _LIBCPP_TYPE_VIS is_compound +template struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant::value> {}; // add_const @@ -519,7 +529,7 @@ struct __add_const {typedef _Tp type;}; template struct __add_const<_Tp, false> {typedef const _Tp type;}; -template struct _LIBCPP_TYPE_VIS add_const +template struct _LIBCPP_TYPE_VIS_ONLY add_const {typedef typename __add_const<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -536,7 +546,7 @@ struct __add_volatile {typedef _Tp type;}; template struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; -template struct _LIBCPP_TYPE_VIS add_volatile +template struct _LIBCPP_TYPE_VIS_ONLY add_volatile {typedef typename __add_volatile<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -545,7 +555,7 @@ template using add_volatile_t = typename add_volatile<_Tp>::type; // add_cv -template struct _LIBCPP_TYPE_VIS add_cv +template struct _LIBCPP_TYPE_VIS_ONLY add_cv {typedef typename add_const::type>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -554,10 +564,10 @@ template using add_cv_t = typename add_cv<_Tp>::type; // remove_reference -template struct _LIBCPP_TYPE_VIS remove_reference {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_reference<_Tp&> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template struct _LIBCPP_TYPE_VIS remove_reference<_Tp&&> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; #endif #if _LIBCPP_STD_VER > 11 @@ -566,12 +576,12 @@ template using remove_reference_t = typename remove_reference<_Tp>:: // add_lvalue_reference -template struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef _Tp& type;}; -template struct _LIBCPP_TYPE_VIS add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef const void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef volatile void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef const volatile void type;}; +template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; +template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef volatile void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; @@ -579,11 +589,11 @@ template using add_lvalue_reference_t = typename add_lvalue_referenc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef _Tp&& type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef const void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef volatile void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef const volatile void type;}; +template struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef volatile void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; @@ -612,11 +622,11 @@ struct __any // remove_pointer -template struct _LIBCPP_TYPE_VIS remove_pointer {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_pointer<_Tp*> {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const> {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; +template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_pointer_t = typename remove_pointer<_Tp>::type; @@ -624,7 +634,7 @@ template using remove_pointer_t = typename remove_pointer<_Tp>::type // add_pointer -template struct _LIBCPP_TYPE_VIS add_pointer +template struct _LIBCPP_TYPE_VIS_ONLY add_pointer {typedef typename remove_reference<_Tp>::type* type;}; #if _LIBCPP_STD_VER > 11 @@ -644,7 +654,7 @@ struct __libcpp_is_signed : public ___is_signed<_Tp> {}; template struct __libcpp_is_signed<_Tp, false> : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; // is_unsigned @@ -659,37 +669,37 @@ struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; // rank -template struct _LIBCPP_TYPE_VIS rank +template struct _LIBCPP_TYPE_VIS_ONLY rank : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS rank<_Tp[]> +template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> : public integral_constant::value + 1> {}; -template struct _LIBCPP_TYPE_VIS rank<_Tp[_Np]> +template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant::value + 1> {}; // extent -template struct _LIBCPP_TYPE_VIS extent +template struct _LIBCPP_TYPE_VIS_ONLY extent : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS extent<_Tp[], 0> +template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS extent<_Tp[], _Ip> +template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> : public integral_constant::value> {}; -template struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], 0> +template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], _Ip> +template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant::value> {}; // remove_extent -template struct _LIBCPP_TYPE_VIS remove_extent +template struct _LIBCPP_TYPE_VIS_ONLY remove_extent {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_extent<_Tp[]> +template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_extent<_Tp[_Np]> +template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 @@ -698,17 +708,42 @@ template using remove_extent_t = typename remove_extent<_Tp>::type; // remove_all_extents -template struct _LIBCPP_TYPE_VIS remove_all_extents +template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents {typedef _Tp type;}; -template struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[]> +template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> {typedef typename remove_all_extents<_Tp>::type type;}; -template struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[_Np]> +template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> {typedef typename remove_all_extents<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif +// decay + +template +struct _LIBCPP_TYPE_VIS_ONLY decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename conditional + < + is_array<_Up>::value, + typename remove_extent<_Up>::type*, + typename conditional + < + is_function<_Up>::value, + typename add_pointer<_Up>::type, + typename remove_cv<_Up>::type + >::type + >::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template using decay_t = typename decay<_Tp>::type; +#endif + // is_abstract namespace __is_abstract_imp @@ -722,14 +757,14 @@ struct __libcpp_abstract : public integral_constant struct __libcpp_abstract<_Tp, false> : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_abstract : public __libcpp_abstract<_Tp> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; // is_base_of -#ifdef _LIBCP_HAS_IS_BASE_OF +#ifdef _LIBCPP_HAS_IS_BASE_OF template -struct _LIBCPP_TYPE_VIS is_base_of +struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant {}; #else // __has_feature(is_base_of) @@ -753,7 +788,7 @@ template __two __test(...); } template -struct _LIBCPP_TYPE_VIS is_base_of +struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant::value && sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; @@ -763,7 +798,7 @@ struct _LIBCPP_TYPE_VIS is_base_of #if __has_feature(is_convertible_to) -template struct _LIBCPP_TYPE_VIS is_convertible +template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public integral_constant::value> {}; @@ -869,7 +904,7 @@ template struct __is_convertible<_T1, _T2, 1, 3> : public template struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; -template struct _LIBCPP_TYPE_VIS is_convertible +template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public __is_convertible<_T1, _T2> { static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; @@ -883,7 +918,7 @@ template struct _LIBCPP_TYPE_VIS is_convertible #if __has_feature(is_empty) template -struct _LIBCPP_TYPE_VIS is_empty +struct _LIBCPP_TYPE_VIS_ONLY is_empty : public integral_constant {}; #else // __has_feature(is_empty) @@ -905,7 +940,7 @@ struct __libcpp_empty : public integral_constant) template struct __libcpp_empty<_Tp, false> : public false_type {}; -template struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_Tp> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; #endif // __has_feature(is_empty) @@ -914,7 +949,7 @@ template struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_T #if __has_feature(is_polymorphic) template -struct _LIBCPP_TYPE_VIS is_polymorphic +struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant {}; #else @@ -924,7 +959,7 @@ template char &__is_polymorphic_impl( int>::type); template __two &__is_polymorphic_impl(...); -template struct _LIBCPP_TYPE_VIS is_polymorphic +template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant(0)) == 1> {}; #endif // __has_feature(is_polymorphic) @@ -933,19 +968,19 @@ template struct _LIBCPP_TYPE_VIS is_polymorphic #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS has_virtual_destructor +template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS -template struct _LIBCPP_TYPE_VIS has_virtual_destructor +template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public false_type {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // alignment_of -template struct _LIBCPP_TYPE_VIS alignment_of +template struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant {}; // aligned_storage @@ -1033,7 +1068,7 @@ struct __find_max_align<__type_list<_Hp, _Tp>, _Len> : public integral_constant::value>::value> {}; template ::value> -struct _LIBCPP_TYPE_VIS aligned_storage +struct _LIBCPP_TYPE_VIS_ONLY aligned_storage { typedef typename __find_pod<__all_types, _Align>::type _Aligner; static_assert(!is_void<_Aligner>::value, ""); @@ -1051,7 +1086,7 @@ template ::valu #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ template \ -struct _LIBCPP_TYPE_VIS aligned_storage<_Len, n>\ +struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ @@ -1074,9 +1109,9 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) -#if !defined(_MSC_VER) +#if !defined(_LIBCPP_MSVC) _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); -#endif // !_MSC_VER +#endif // !_LIBCPP_MSVC #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION @@ -1270,7 +1305,7 @@ template <> struct __make_signed< signed long long, true> {typedef long long ty template <> struct __make_signed {typedef long long type;}; template -struct _LIBCPP_TYPE_VIS make_signed +struct _LIBCPP_TYPE_VIS_ONLY make_signed { typedef typename __apply_cv<_Tp, typename __make_signed::type>::type>::type type; }; @@ -1299,7 +1334,7 @@ template <> struct __make_unsigned< signed long long, true> {typedef unsigned l template <> struct __make_unsigned {typedef unsigned long long type;}; template -struct _LIBCPP_TYPE_VIS make_unsigned +struct _LIBCPP_TYPE_VIS_ONLY make_unsigned { typedef typename __apply_cv<_Tp, typename __make_unsigned::type>::type>::type type; }; @@ -1311,21 +1346,21 @@ template using make_unsigned_t = typename make_unsigned<_Tp>::type; #ifdef _LIBCPP_HAS_NO_VARIADICS template -struct _LIBCPP_TYPE_VIS common_type +struct _LIBCPP_TYPE_VIS_ONLY common_type { public: typedef typename common_type::type, V>::type type; }; template -struct _LIBCPP_TYPE_VIS common_type<_Tp, void, void> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> { public: typedef _Tp type; }; template -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, void> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1344,24 +1379,24 @@ public: template struct common_type; template -struct _LIBCPP_TYPE_VIS common_type<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { - typedef _Tp type; + typedef typename decay<_Tp>::type type; }; template -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> { private: static _Tp&& __t(); static _Up&& __u(); static bool __f(); public: - typedef typename remove_reference::type type; + typedef typename decay::type type; }; template -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, _Vp...> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> { typedef typename common_type::type, _Vp...>::type type; }; @@ -1374,8 +1409,10 @@ template using common_type_t = typename common_type<_Tp...>::type // is_assignable +template struct __select_2nd { typedef _Tp type; }; + template -decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type())) +typename __select_2nd() = _VSTD::declval<_Arg>())), true_type>::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(_Tp&&, _Arg&&); #else @@ -1409,13 +1446,13 @@ struct is_assignable // is_copy_assignable -template struct _LIBCPP_TYPE_VIS is_copy_assignable +template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_assignable -template struct _LIBCPP_TYPE_VIS is_move_assignable +template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_assignable::type, const typename add_rvalue_reference<_Tp>::type> {}; @@ -1442,7 +1479,8 @@ __is_destructible_test(_Tp&); false_type __is_destructible_test(__any); -template ::value || is_abstract<_Tp>::value> +template ::value || is_abstract<_Tp>::value + || is_function<_Tp>::value> struct __destructible_imp : public common_type < @@ -1457,12 +1495,16 @@ template struct is_destructible : public __destructible_imp<_Tp> {}; +template +struct is_destructible<_Tp[]> + : public false_type {}; + // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename remove_reference<_Tp>::type&& move(_Tp&& __t) _NOEXCEPT { @@ -1471,7 +1513,7 @@ move(_Tp&& __t) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT { @@ -1479,7 +1521,7 @@ forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT { @@ -1529,29 +1571,6 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -template -struct _LIBCPP_TYPE_VIS decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; -public: - typedef typename conditional - < - is_array<_Up>::value, - typename remove_extent<_Up>::type*, - typename conditional - < - is_function<_Up>::value, - typename add_pointer<_Up>::type, - typename remove_cv<_Up>::type - >::type - >::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template using decay_t = typename decay<_Tp>::type; -#endif - #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template @@ -1913,7 +1932,7 @@ class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member p // result_of template -class _LIBCPP_TYPE_VIS result_of<_Fn()> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> : public __result_of<_Fn(), is_class::type>::value || is_function::type>::value, @@ -1923,7 +1942,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn()> }; template -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> : public __result_of<_Fn(_A0), is_class::type>::value || is_function::type>::value, @@ -1933,7 +1952,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0)> }; template -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> : public __result_of<_Fn(_A0, _A1), is_class::type>::value || is_function::type>::value, @@ -1943,7 +1962,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)> }; template -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> : public __result_of<_Fn(_A0, _A1, _A2), is_class::type>::value || is_function::type>::value, @@ -1960,8 +1979,6 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)> // main is_constructible test -template struct __select_2nd { typedef T type; }; - template typename __select_2nd()...))), true_type>::type __is_constructible_test(_Tp&&, _Args&& ...); @@ -2048,7 +2065,7 @@ struct __contains_void<_A0, _Args...> // is_constructible entry point template -struct _LIBCPP_TYPE_VIS is_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value || is_abstract<_Tp>::value, _Tp, _Args...> @@ -2196,7 +2213,7 @@ struct __nat {}; template -struct _LIBCPP_TYPE_VIS is_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible2_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value @@ -2206,7 +2223,7 @@ struct _LIBCPP_TYPE_VIS is_constructible {}; template -struct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> +struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : public __is_constructible0_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value, @@ -2214,7 +2231,7 @@ struct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_constr {}; template -struct _LIBCPP_TYPE_VIS is_constructible<_Tp, _A0, __is_construct::__nat> +struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> : public __is_constructible1_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value @@ -2262,21 +2279,21 @@ struct __is_constructible2_imp // is_default_constructible template -struct _LIBCPP_TYPE_VIS is_default_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; // is_copy_constructible template -struct _LIBCPP_TYPE_VIS is_copy_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_constructible template -struct _LIBCPP_TYPE_VIS is_move_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2291,7 +2308,7 @@ struct _LIBCPP_TYPE_VIS is_move_constructible #if __has_feature(is_trivially_constructible) template -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : integral_constant { }; @@ -2299,13 +2316,13 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible #else // !__has_feature(is_trivially_constructible) template -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else @@ -2316,22 +2333,22 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp> template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> #else -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> #endif : integral_constant::value> { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> : integral_constant::value> { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> : integral_constant::value> { }; @@ -2342,7 +2359,7 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&> template -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; @@ -2350,28 +2367,28 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible #if __has_feature(is_trivially_constructible) template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant { @@ -2380,28 +2397,28 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, #else // !__has_feature(is_trivially_constructible) template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant::value> { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant::value> { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant::value> { }; template -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant::value> { @@ -2413,19 +2430,19 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, // is_trivially_default_constructible -template struct _LIBCPP_TYPE_VIS is_trivially_default_constructible +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; // is_trivially_copy_constructible -template struct _LIBCPP_TYPE_VIS is_trivially_copy_constructible - : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible + : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> {}; // is_trivially_move_constructible -template struct _LIBCPP_TYPE_VIS is_trivially_move_constructible +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2473,14 +2490,14 @@ struct is_trivially_assignable<_Tp&, _Tp&&> // is_trivially_copy_assignable -template struct _LIBCPP_TYPE_VIS 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> {}; // is_trivially_move_assignable -template struct _LIBCPP_TYPE_VIS is_trivially_move_assignable +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable : public is_trivially_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> @@ -2493,7 +2510,7 @@ template struct _LIBCPP_TYPE_VIS is_trivially_move_assignable #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS is_trivially_destructible +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS @@ -2502,7 +2519,7 @@ template struct __libcpp_trivial_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; -template struct _LIBCPP_TYPE_VIS is_trivially_destructible +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS @@ -2528,13 +2545,13 @@ struct __is_nothrow_constructible }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : __is_nothrow_constructible::value, _Tp, _Args...> { }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> : __is_nothrow_constructible::value, _Tp> { }; @@ -2542,13 +2559,13 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]> #else // __has_feature(cxx_noexcept) template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else @@ -2559,9 +2576,9 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp> template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> #else -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> #endif #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant @@ -2572,7 +2589,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp> }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else @@ -2582,7 +2599,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&> }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else @@ -2597,13 +2614,13 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&> template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, +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) : integral_constant @@ -2614,7 +2631,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp, +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) : integral_constant @@ -2625,7 +2642,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp, }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&, +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) : integral_constant @@ -2636,7 +2653,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&, }; template -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&, +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) : integral_constant @@ -2650,19 +2667,19 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&, // is_nothrow_default_constructible -template struct _LIBCPP_TYPE_VIS is_nothrow_default_constructible +template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; // is_nothrow_copy_constructible -template struct _LIBCPP_TYPE_VIS 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> {}; // is_nothrow_move_constructible -template struct _LIBCPP_TYPE_VIS is_nothrow_move_constructible +template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2689,7 +2706,7 @@ struct __is_nothrow_assignable }; template -struct _LIBCPP_TYPE_VIS is_nothrow_assignable +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public __is_nothrow_assignable::value, _Tp, _Arg> { }; @@ -2697,11 +2714,11 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable #else // __has_feature(cxx_noexcept) template -struct _LIBCPP_TYPE_VIS is_nothrow_assignable +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public false_type {}; template -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else @@ -2709,7 +2726,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp> #endif template -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else @@ -2717,7 +2734,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&> #endif template -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else @@ -2740,14 +2757,14 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> // is_nothrow_copy_assignable -template struct _LIBCPP_TYPE_VIS is_nothrow_copy_assignable +template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_assignable -template struct _LIBCPP_TYPE_VIS is_nothrow_move_assignable +template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable : public is_nothrow_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> @@ -2775,19 +2792,19 @@ struct __is_nothrow_destructible }; template -struct _LIBCPP_TYPE_VIS is_nothrow_destructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __is_nothrow_destructible::value, _Tp> { }; template -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp[_Ns]> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> { }; template -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> : public true_type { }; @@ -2795,7 +2812,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> : public true_type { }; @@ -2808,7 +2825,7 @@ template struct __libcpp_nothrow_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; -template struct _LIBCPP_TYPE_VIS is_nothrow_destructible +template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; #endif @@ -2817,12 +2834,12 @@ template struct _LIBCPP_TYPE_VIS is_nothrow_destructible #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template struct _LIBCPP_TYPE_VIS is_pod +template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS -template struct _LIBCPP_TYPE_VIS is_pod +template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant::value && is_trivially_copy_constructible<_Tp>::value && is_trivially_copy_assignable<_Tp>::value && @@ -2832,7 +2849,7 @@ template struct _LIBCPP_TYPE_VIS is_pod // is_literal_type; -template struct _LIBCPP_TYPE_VIS is_literal_type +template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #if __has_feature(is_literal) : public integral_constant #else @@ -2843,7 +2860,7 @@ template struct _LIBCPP_TYPE_VIS is_literal_type // is_standard_layout; -template struct _LIBCPP_TYPE_VIS is_standard_layout +template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #if __has_feature(is_standard_layout) : public integral_constant #else @@ -2853,7 +2870,7 @@ template struct _LIBCPP_TYPE_VIS is_standard_layout // is_trivially_copyable; -template struct _LIBCPP_TYPE_VIS is_trivially_copyable +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #if __has_feature(is_trivially_copyable) : public integral_constant #else @@ -2863,7 +2880,7 @@ template struct _LIBCPP_TYPE_VIS is_trivially_copyable // is_trivial; -template struct _LIBCPP_TYPE_VIS is_trivial +template struct _LIBCPP_TYPE_VIS_ONLY is_trivial #if __has_feature(is_trivial) : public integral_constant #else @@ -2920,12 +2937,22 @@ struct __check_complete<_Rp (*)(_Param...)> { }; +template +struct __check_complete +{ +}; + template struct __check_complete<_Rp (_Param...)> : private __check_complete<_Rp> { }; +template +struct __check_complete +{ +}; + template struct __check_complete<_Rp (_Class::*)(_Param...)> : private __check_complete<_Class> @@ -3120,7 +3147,7 @@ struct __invoke_of }; template -class _LIBCPP_TYPE_VIS result_of<_Fp(_Args...)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> { }; @@ -3239,6 +3266,27 @@ struct underlying_type #endif // _LIBCXX_UNDERLYING_TYPE +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + +template +struct __has_operator_addressof_imp +{ + template + static auto __test(__any) -> false_type; + template + static auto __test(_Up* __u) + -> typename __select_2ndoperator&()), true_type>::type; + + static const bool value = decltype(__test<_Tp>(nullptr))::value; +}; + +template +struct __has_operator_addressof + : public integral_constant::value> +{}; + +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS diff --git a/contrib/libc++/include/typeindex b/contrib/libc++/include/typeindex index 67462b742..d4d6ca96b 100644 --- a/contrib/libc++/include/typeindex +++ b/contrib/libc++/include/typeindex @@ -55,7 +55,7 @@ struct hash _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_TYPE_VIS type_index +class _LIBCPP_TYPE_VIS_ONLY type_index { const type_info* __t_; public: @@ -87,10 +87,10 @@ public: const char* name() const _NOEXCEPT {return __t_->name();} }; -template struct _LIBCPP_TYPE_VIS hash; +template struct _LIBCPP_TYPE_VIS_ONLY hash; template <> -struct _LIBCPP_TYPE_VIS hash +struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/unordered_map b/contrib/libc++/include/unordered_map index 78e630757..78fee4811 100644 --- a/contrib/libc++/include/unordered_map +++ b/contrib/libc++/include/unordered_map @@ -69,6 +69,22 @@ public: unordered_map(initializer_list, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_map(size_type n, const allocator_type& a) + : unordered_map(n, hasher(), key_equal(), a) {} // C++14 + unordered_map(size_type n, const hasher& hf, const allocator_type& a) + : unordered_map(n, hf, key_equal(), a) {} // C++14 + template + unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 + template + unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_map(initializer_list il, size_type n, const allocator_type& a) + : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_map(initializer_list il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(il, n, hf, key_equal(), a) {} // C++14 ~unordered_map(); unordered_map& operator=(const unordered_map&); unordered_map& operator=(unordered_map&&) @@ -217,6 +233,22 @@ public: unordered_multimap(initializer_list, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multimap(size_type n, const allocator_type& a) + : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) + : unordered_multimap(n, hf, key_equal(), a) {} // C++14 + template + unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 + template + unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_multimap(initializer_list il, size_type n, const allocator_type& a) + : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(initializer_list il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 ~unordered_multimap(); unordered_multimap& operator=(const unordered_multimap&); unordered_multimap& operator=(unordered_multimap&&) @@ -493,8 +525,73 @@ public: } }; +#if __cplusplus >= 201103L + +template +union __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair value_type; + typedef pair __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const __hash_value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(__hash_value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(const __hash_value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(__hash_value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__hash_value_type() {__cc.~value_type();} +}; + +#else + +template +struct __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type() {} + + template + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0) + : __cc(__a0) {} + + template + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template -class _LIBCPP_TYPE_VIS __hash_map_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; @@ -542,15 +639,15 @@ public: bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS unordered_map; - template friend class _LIBCPP_TYPE_VIS unordered_multimap; - template friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template -class _LIBCPP_TYPE_VIS __hash_map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; @@ -603,15 +700,15 @@ public: bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TYPE_VIS unordered_map; - template friend class _LIBCPP_TYPE_VIS unordered_multimap; - template friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; }; template , class _Pred = equal_to<_Key>, class _Alloc = allocator > > -class _LIBCPP_TYPE_VIS unordered_map +class _LIBCPP_TYPE_VIS_ONLY unordered_map { public: // types @@ -624,51 +721,11 @@ public: typedef pair __nc_value_type; typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_map::value_type value_type; - typedef typename unordered_map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_map::value_type value_type; - value_type __cc; - - __value_type() {} - - template - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type __value_type; typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; typedef typename allocator_traits::template @@ -706,7 +763,11 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) - {} // = default; + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + } explicit unordered_map(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); unordered_map(size_type __n, const hasher& __hf, @@ -739,6 +800,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) {} + template + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {} + template + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list __il, size_type __n, const allocator_type& __a) + : unordered_map(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_map() = default; _LIBCPP_INLINE_VISIBILITY unordered_map& operator=(const unordered_map& __u) @@ -795,8 +880,18 @@ public: template _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator emplace_hint(const_iterator __p, _Args&&... __args) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered_map"); + return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; + } +#else iterator emplace_hint(const_iterator, _Args&&... __args) {return emplace(_VSTD::forward<_Args>(__args)...).first;} +#endif #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY @@ -810,14 +905,34 @@ public: {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator insert(const_iterator __p, const value_type& __x) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" + " referring to this unordered_map"); + return insert(__x).first; + } +#else iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;} +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template ::value>::type> _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator insert(const_iterator __p, _Pp&& __x) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" + " referring to this unordered_map"); + return insert(_VSTD::forward<_Pp>(__x)).first; + } +#else iterator insert(const_iterator, _Pp&& __x) {return insert(_VSTD::forward<_Pp>(__x)).first;} +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void insert(_InputIterator __first, _InputIterator __last); @@ -905,6 +1020,19 @@ public: _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) {__table_.reserve(__n);} +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const + {return __table_.__dereferenceable(&__i->__i_);} + bool __decrementable(const const_iterator* __i) const + {return __table_.__decrementable(&__i->__i_);} + bool __addable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(&__i->__i_, __n);} + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(&__i->__i_, __n);} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __node_holder __construct_node(); @@ -925,6 +1053,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( size_type __n, const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -934,6 +1065,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -943,6 +1077,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const allocator_type& __a) : __table_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -950,6 +1087,9 @@ template unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__first, __last); } @@ -960,6 +1100,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -971,6 +1114,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -980,6 +1126,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const unordered_map& __u) : __table_(__u.__table_) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -989,6 +1138,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const unordered_map& __u, const allocator_type& __a) : __table_(__u.__table_, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -1002,6 +1154,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_VSTD::move(__u.__table_)) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + __get_db()->swap(this, &__u); +#endif } template @@ -1009,6 +1165,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( unordered_map&& __u, const allocator_type& __a) : __table_(_VSTD::move(__u.__table_), __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__a != __u.get_allocator()) { iterator __i = __u.begin(); @@ -1017,6 +1176,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_) ); } +#if _LIBCPP_DEBUG_LEVEL >= 2 + else + __get_db()->swap(this, &__u); +#endif } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1027,6 +1190,9 @@ template unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( initializer_list __il) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__il.begin(), __il.end()); } @@ -1036,6 +1202,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -1046,6 +1215,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -1118,7 +1290,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1165,7 +1337,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template @@ -1273,7 +1445,7 @@ operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, template , class _Pred = equal_to<_Key>, class _Alloc = allocator > > -class _LIBCPP_TYPE_VIS unordered_multimap +class _LIBCPP_TYPE_VIS_ONLY unordered_multimap { public: // types @@ -1286,51 +1458,11 @@ public: typedef pair __nc_value_type; typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_multimap::value_type value_type; - typedef typename unordered_multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type __value_type; typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; typedef typename allocator_traits::template @@ -1366,7 +1498,11 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) - {} // = default; + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + } explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); unordered_multimap(size_type __n, const hasher& __hf, @@ -1400,6 +1536,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) {} + template + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {} + template + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list __il, size_type __n, const allocator_type& __a) + : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_multimap() = default; _LIBCPP_INLINE_VISIBILITY unordered_multimap& operator=(const unordered_multimap& __u) @@ -1556,6 +1716,19 @@ public: _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) {__table_.reserve(__n);} +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const + {return __table_.__dereferenceable(&__i->__i_);} + bool __decrementable(const const_iterator* __i) const + {return __table_.__decrementable(&__i->__i_);} + bool __addable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(&__i->__i_, __n);} + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(&__i->__i_, __n);} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __node_holder __construct_node(); @@ -1574,6 +1747,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( size_type __n, const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -1583,6 +1759,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -1591,6 +1770,9 @@ template unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__first, __last); } @@ -1601,6 +1783,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -1612,6 +1797,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -1622,6 +1810,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const allocator_type& __a) : __table_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -1629,6 +1820,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const unordered_multimap& __u) : __table_(__u.__table_) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -1638,6 +1832,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const unordered_multimap& __u, const allocator_type& __a) : __table_(__u.__table_, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -1651,6 +1848,10 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_VSTD::move(__u.__table_)) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + __get_db()->swap(this, &__u); +#endif } template @@ -1658,16 +1859,23 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( unordered_multimap&& __u, const allocator_type& __a) : __table_(_VSTD::move(__u.__table_), __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__a != __u.get_allocator()) { iterator __i = __u.begin(); while (__u.size() != 0) -{ + { __table_.__insert_multi( _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_) ); -} + } } +#if _LIBCPP_DEBUG_LEVEL >= 2 + else + __get_db()->swap(this, &__u); +#endif } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1678,6 +1886,9 @@ template unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( initializer_list __il) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__il.begin(), __il.end()); } @@ -1687,6 +1898,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -1697,6 +1911,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } diff --git a/contrib/libc++/include/unordered_set b/contrib/libc++/include/unordered_set index 119251dc3..fd378fa07 100644 --- a/contrib/libc++/include/unordered_set +++ b/contrib/libc++/include/unordered_set @@ -68,6 +68,16 @@ public: unordered_set(initializer_list, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_set(size_type n, const allocator_type& a); // C++14 + unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template + unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template + unordered_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_set(initializer_list il, size_type n, const allocator_type& a); // C++14 + unordered_set(initializer_list il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_set(); unordered_set& operator=(const unordered_set&); unordered_set& operator=(unordered_set&&) @@ -207,6 +217,16 @@ public: unordered_multiset(initializer_list, size_type n = /see below/, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multiset(size_type n, const allocator_type& a); // C++14 + unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template + unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template + unordered_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_multiset(initializer_list il, size_type n, const allocator_type& a); // C++14 + unordered_multiset(initializer_list il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_multiset(); unordered_multiset& operator=(const unordered_multiset&); unordered_multiset& operator=(unordered_multiset&&) @@ -313,7 +333,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template , class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS unordered_set +class _LIBCPP_TYPE_VIS_ONLY unordered_set { public: // types @@ -324,6 +344,8 @@ public: typedef _Alloc allocator_type; typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Invalid allocator::value_type"); private: typedef __hash_table __table; @@ -344,9 +366,21 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) - {} // = default; + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + } explicit unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) {} +#endif unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); template @@ -359,6 +393,17 @@ public: unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_set(const allocator_type& __a); unordered_set(const unordered_set& __u); unordered_set(const unordered_set& __u, const allocator_type& __a); @@ -375,6 +420,16 @@ public: unordered_set(initializer_list __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list __il, size_type __n, + const allocator_type& __a) + : unordered_set(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list __il, size_type __n, + const hasher& __hf, const allocator_type& __a) + : unordered_set(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_set() = default; _LIBCPP_INLINE_VISIBILITY @@ -422,8 +477,18 @@ public: {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} template _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator emplace_hint(const_iterator __p, _Args&&... __args) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered_set"); + return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; + } +#else iterator emplace_hint(const_iterator, _Args&&... __args) {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;} +#endif #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) _LIBCPP_INLINE_VISIBILITY pair insert(const value_type& __x) @@ -434,12 +499,32 @@ public: {return __table_.__insert_unique(_VSTD::move(__x));} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator insert(const_iterator __p, const value_type& __x) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_set::insert(const_iterator, const value_type&) called with an iterator not" + " referring to this unordered_set"); + return insert(__x).first; + } +#else iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;} +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY +#if _LIBCPP_DEBUG_LEVEL >= 2 + iterator insert(const_iterator __p, value_type&& __x) + { + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_set::insert(const_iterator, value_type&&) called with an iterator not" + " referring to this unordered_set"); + return insert(_VSTD::move(__x)).first; + } +#else iterator insert(const_iterator, value_type&& __x) {return insert(_VSTD::move(__x)).first;} +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void insert(_InputIterator __first, _InputIterator __last); @@ -515,6 +600,20 @@ public: void rehash(size_type __n) {__table_.rehash(__n);} _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) {__table_.reserve(__n);} + +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const + {return __table_.__dereferenceable(__i);} + bool __decrementable(const const_iterator* __i) const + {return __table_.__decrementable(__i);} + bool __addable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(__i, __n);} + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(__i, __n);} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + }; template @@ -522,6 +621,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -530,6 +632,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -538,6 +643,9 @@ template unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__first, __last); } @@ -548,6 +656,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -559,6 +670,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -569,6 +683,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const allocator_type& __a) : __table_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -576,6 +693,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const unordered_set& __u) : __table_(__u.__table_) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -585,6 +705,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const unordered_set& __u, const allocator_type& __a) : __table_(__u.__table_, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -598,6 +721,10 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_VSTD::move(__u.__table_)) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + __get_db()->swap(this, &__u); +#endif } template @@ -605,12 +732,19 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( unordered_set&& __u, const allocator_type& __a) : __table_(_VSTD::move(__u.__table_), __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__a != __u.get_allocator()) { iterator __i = __u.begin(); while (__u.size() != 0) __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); } +#if _LIBCPP_DEBUG_LEVEL >= 2 + else + __get_db()->swap(this, &__u); +#endif } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -621,6 +755,9 @@ template unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( initializer_list __il) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__il.begin(), __il.end()); } @@ -630,6 +767,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -640,6 +780,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -725,7 +868,7 @@ operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, template , class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS unordered_multiset +class _LIBCPP_TYPE_VIS_ONLY unordered_multiset { public: // types @@ -736,6 +879,8 @@ public: typedef _Alloc allocator_type; typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Invalid allocator::value_type"); private: typedef __hash_table __table; @@ -756,11 +901,23 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) - {} // = default + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + } explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) {} +#endif template unordered_multiset(_InputIterator __first, _InputIterator __last); template @@ -771,6 +928,18 @@ public: unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n , const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} + template + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_multiset(const allocator_type& __a); unordered_multiset(const unordered_multiset& __u); unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); @@ -787,6 +956,14 @@ public: unordered_multiset(initializer_list __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list __il, size_type __n, const allocator_type& __a) + : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list __il, size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_multiset() = default; _LIBCPP_INLINE_VISIBILITY @@ -925,6 +1102,20 @@ public: void rehash(size_type __n) {__table_.rehash(__n);} _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) {__table_.reserve(__n);} + +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const + {return __table_.__dereferenceable(__i);} + bool __decrementable(const const_iterator* __i) const + {return __table_.__decrementable(__i);} + bool __addable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(__i, __n);} + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const + {return __table_.__addable(__i, __n);} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + }; template @@ -932,6 +1123,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( size_type __n, const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -941,6 +1135,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); } @@ -949,6 +1146,9 @@ template unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__first, __last); } @@ -959,6 +1159,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const hasher& __hf, const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -970,6 +1173,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__first, __last); } @@ -980,6 +1186,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const allocator_type& __a) : __table_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template @@ -987,6 +1196,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const unordered_multiset& __u) : __table_(__u.__table_) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -996,6 +1208,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const unordered_multiset& __u, const allocator_type& __a) : __table_(__u.__table_, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__u.bucket_count()); insert(__u.begin(), __u.end()); } @@ -1009,6 +1224,10 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_VSTD::move(__u.__table_)) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + __get_db()->swap(this, &__u); +#endif } template @@ -1016,12 +1235,19 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( unordered_multiset&& __u, const allocator_type& __a) : __table_(_VSTD::move(__u.__table_), __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__a != __u.get_allocator()) { iterator __i = __u.begin(); while (__u.size() != 0) __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); } +#if _LIBCPP_DEBUG_LEVEL >= 2 + else + __get_db()->swap(this, &__u); +#endif } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1032,6 +1258,9 @@ template unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( initializer_list __il) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif insert(__il.begin(), __il.end()); } @@ -1041,6 +1270,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const key_equal& __eql) : __table_(__hf, __eql) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } @@ -1051,6 +1283,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( const key_equal& __eql, const allocator_type& __a) : __table_(__hf, __eql, __a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __table_.rehash(__n); insert(__il.begin(), __il.end()); } diff --git a/contrib/libc++/include/utility b/contrib/libc++/include/utility index ba656493c..2c1f62ccb 100644 --- a/contrib/libc++/include/utility +++ b/contrib/libc++/include/utility @@ -38,10 +38,10 @@ template void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b))); -template T&& forward(typename remove_reference::type& t) noexcept; -template T&& forward(typename remove_reference::type&& t) noexcept; +template T&& forward(typename remove_reference::type& t) noexcept; // constexpr in C++14 +template T&& forward(typename remove_reference::type&& t) noexcept; // constexpr in C++14 -template typename remove_reference::type&& move(T&&) noexcept; +template typename remove_reference::type&& move(T&&) noexcept; // constexpr in C++14 template typename conditional @@ -50,7 +50,7 @@ template const T&, T&& >::type - move_if_noexcept(T& x) noexcept; + move_if_noexcept(T& x) noexcept; // constexpr in C++14 template typename add_rvalue_reference::type declval() noexcept; @@ -66,10 +66,10 @@ struct pair pair(const pair&) = default; pair(pair&&) = default; constexpr pair(); - pair(const T1& x, const T2& y); - template pair(U&& x, V&& y); - template pair(const pair& p); - template pair(pair&& p); + pair(const T1& x, const T2& y); // constexpr in C++14 + template pair(U&& x, V&& y); // constexpr in C++14 + template pair(const pair& p); // constexpr in C++14 + template pair(pair&& p); // constexpr in C++14 template pair(piecewise_construct_t, tuple first_args, tuple second_args); @@ -83,14 +83,14 @@ struct pair noexcept(swap(second, p.second))); }; -template bool operator==(const pair&, const pair&); -template bool operator!=(const pair&, const pair&); -template bool operator< (const pair&, const pair&); -template bool operator> (const pair&, const pair&); -template bool operator>=(const pair&, const pair&); -template bool operator<=(const pair&, const pair&); +template bool operator==(const pair&, const pair&); // constexpr in C++14 +template bool operator!=(const pair&, const pair&); // constexpr in C++14 +template bool operator< (const pair&, const pair&); // constexpr in C++14 +template bool operator> (const pair&, const pair&); // constexpr in C++14 +template bool operator>=(const pair&, const pair&); // constexpr in C++14 +template bool operator<=(const pair&, const pair&); // constexpr in C++14 -template pair make_pair(T1&&, T2&&); +template pair make_pair(T1&&, T2&&); // constexpr in C++14 template void swap(pair& x, pair& y) noexcept(noexcept(x.swap(y))); @@ -107,15 +107,24 @@ template struct tuple_element<1, std::pair >; template typename tuple_element >::type& - get(std::pair&) noexcept; + get(std::pair&) noexcept; // constexpr in C++14 template const typename const tuple_element >::type& - get(const std::pair&) noexcept; + get(const std::pair&) noexcept; // constexpr in C++14 template typename tuple_element >::type&& - get(std::pair&&) noexcept; + get(std::pair&&) noexcept; // constexpr in C++14 + +template + constexpr T1& get(std::pair&) noexcept; // C++14 + +template + constexpr T1 const& get(std::pair const &) noexcept; // C++14 + +template + constexpr T1&& get(std::pair&&) noexcept; // C++14 // C++14 @@ -138,6 +147,8 @@ template template using index_sequence_for = make_index_sequence; +template + T exchange(T& obj, U&& new_value); } // std */ @@ -210,7 +221,7 @@ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::v } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename conditional < @@ -226,7 +237,7 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT return _VSTD::move(__x); } -struct _LIBCPP_TYPE_VIS piecewise_construct_t { }; +struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { }; #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY) extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); #else @@ -234,7 +245,7 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); #endif template -struct _LIBCPP_TYPE_VIS pair +struct _LIBCPP_TYPE_VIS_ONLY pair { typedef _T1 first_type; typedef _T2 second_type; @@ -247,11 +258,12 @@ struct _LIBCPP_TYPE_VIS pair _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} - _LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + pair(const _T1& __x, const _T2& __y) : first(__x), second(__y) {} template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(const pair<_U1, _U2>& __p #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE ,typename enable_if::value && @@ -260,6 +272,10 @@ struct _LIBCPP_TYPE_VIS pair ) : first(__p.first), second(__p.second) {} +#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR + _LIBCPP_INLINE_VISIBILITY + pair(const pair& __p) = default; +#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR _LIBCPP_INLINE_VISIBILITY pair(const pair& __p) _NOEXCEPT_(is_nothrow_copy_constructible::value && @@ -268,6 +284,7 @@ struct _LIBCPP_TYPE_VIS pair second(__p.second) { } +#endif _LIBCPP_INLINE_VISIBILITY pair& operator=(const pair& __p) @@ -284,20 +301,24 @@ struct _LIBCPP_TYPE_VIS pair template ::value && is_convertible<_U2, second_type>::value>::type> - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_U1&& __u1, _U2&& __u2) : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} template - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(pair<_U1, _U2>&& __p, typename enable_if::value && is_convertible<_U2, _T2>::value>::type* = 0) : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} +#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + _LIBCPP_INLINE_VISIBILITY + pair(pair&& __p) = default; +#else _LIBCPP_INLINE_VISIBILITY pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible::value && is_nothrow_move_constructible::value) @@ -305,6 +326,7 @@ struct _LIBCPP_TYPE_VIS pair second(_VSTD::forward(__p.second)) { } +#endif _LIBCPP_INLINE_VISIBILITY pair& @@ -320,7 +342,7 @@ struct _LIBCPP_TYPE_VIS pair template::value>::type> - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_Tuple&& __p) : first(_VSTD::forward::type>::type>(get<0>(__p))), @@ -376,7 +398,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -384,7 +406,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -392,7 +414,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -400,7 +422,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -408,7 +430,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -416,7 +438,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { @@ -440,7 +462,7 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template class _LIBCPP_TYPE_VIS reference_wrapper; +template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template struct ___make_pair_return @@ -461,7 +483,7 @@ struct __make_pair_return }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair::type, typename __make_pair_return<_T2>::type> make_pair(_T1&& __t1, _T2&& __t2) { @@ -482,36 +504,36 @@ make_pair(_T1 __x, _T2 __y) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template - class _LIBCPP_TYPE_VIS tuple_size > + class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; template - class _LIBCPP_TYPE_VIS tuple_size > + class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; template -class _LIBCPP_TYPE_VIS tuple_element<0, pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> > { public: typedef _T1 type; }; template -class _LIBCPP_TYPE_VIS tuple_element<1, pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> > { public: typedef _T2 type; }; template -class _LIBCPP_TYPE_VIS tuple_element<0, const pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> > { public: typedef const _T1 type; }; template -class _LIBCPP_TYPE_VIS tuple_element<1, const pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> > { public: typedef const _T2 type; @@ -524,13 +546,13 @@ struct __get_pair<0> { template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T1& get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} @@ -538,7 +560,7 @@ struct __get_pair<0> template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} @@ -550,13 +572,13 @@ struct __get_pair<1> { template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T2& get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} @@ -564,7 +586,7 @@ struct __get_pair<1> template static - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} @@ -572,7 +594,7 @@ struct __get_pair<1> }; template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(pair<_T1, _T2>& __p) _NOEXCEPT { @@ -580,7 +602,7 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>& __p) _NOEXCEPT { @@ -590,7 +612,7 @@ get(const pair<_T1, _T2>& __p) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { @@ -599,10 +621,55 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT +{ + return __get_pair<0>::get(__p); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT +{ + return __get_pair<0>::get(__p); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT +{ + return __get_pair<0>::get(_VSTD::move(__p)); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT +{ + return __get_pair<1>::get(__p); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT +{ + return __get_pair<1>::get(__p); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT +{ + return __get_pair<1>::get(_VSTD::move(__p)); +} + +#endif + #if _LIBCPP_STD_VER > 11 template -struct _LIBCPP_TYPE_VIS integer_sequence +struct _LIBCPP_TYPE_VIS_ONLY integer_sequence { typedef _Tp value_type; static_assert( is_integral<_Tp>::value, @@ -685,6 +752,17 @@ template #endif // _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +_T1 exchange(_T1& __obj, _T2 && __new_value) +{ + _T1 __old_value = _VSTD::move(__obj); + __obj = _VSTD::forward<_T2>(__new_value); + return __old_value; +} +#endif // _LIBCPP_STD_VER > 11 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_UTILITY diff --git a/contrib/libc++/include/valarray b/contrib/libc++/include/valarray index 71c8a74ed..5113516e9 100644 --- a/contrib/libc++/include/valarray +++ b/contrib/libc++/include/valarray @@ -354,9 +354,9 @@ template unspecified2 end(const valarray& v); _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS valarray; +template class _LIBCPP_TYPE_VIS_ONLY valarray; -class _LIBCPP_TYPE_VIS slice +class _LIBCPP_TYPE_VIS_ONLY slice { size_t __start_; size_t __size_; @@ -381,11 +381,11 @@ public: _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} }; -template class _LIBCPP_TYPE_VIS slice_array; +template class _LIBCPP_TYPE_VIS_ONLY slice_array; class _LIBCPP_TYPE_VIS gslice; -template class _LIBCPP_TYPE_VIS gslice_array; -template class _LIBCPP_TYPE_VIS mask_array; -template class _LIBCPP_TYPE_VIS indirect_array; +template class _LIBCPP_TYPE_VIS_ONLY gslice_array; +template class _LIBCPP_TYPE_VIS_ONLY mask_array; +template class _LIBCPP_TYPE_VIS_ONLY indirect_array; template _LIBCPP_INLINE_VISIBILITY @@ -671,7 +671,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} - template friend class _LIBCPP_TYPE_VIS valarray; + template friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template @@ -786,7 +786,7 @@ template struct __is_val_expr > : true_type {}; template -class _LIBCPP_TYPE_VIS valarray +class _LIBCPP_TYPE_VIS_ONLY valarray { public: typedef _Tp value_type; @@ -976,12 +976,12 @@ public: void resize(size_t __n, value_type __x = value_type()); private: - template friend class _LIBCPP_TYPE_VIS valarray; - template friend class _LIBCPP_TYPE_VIS slice_array; - template friend class _LIBCPP_TYPE_VIS gslice_array; - template friend class _LIBCPP_TYPE_VIS mask_array; + template friend class _LIBCPP_TYPE_VIS_ONLY valarray; + template friend class _LIBCPP_TYPE_VIS_ONLY slice_array; + template friend class _LIBCPP_TYPE_VIS_ONLY gslice_array; + template friend class _LIBCPP_TYPE_VIS_ONLY mask_array; template friend class __mask_expr; - template friend class _LIBCPP_TYPE_VIS indirect_array; + template friend class _LIBCPP_TYPE_VIS_ONLY indirect_array; template friend class __indirect_expr; template friend class __val_expr; @@ -1006,6 +1006,10 @@ private: end(const valarray<_Up>& __v); }; +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::valarray(size_t)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::~valarray()) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray::resize(size_t, size_t)) + template struct _UnaryOp<_Op, valarray<_Tp> > { @@ -1091,7 +1095,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > // slice_array template -class _LIBCPP_TYPE_VIS slice_array +class _LIBCPP_TYPE_VIS_ONLY slice_array { public: typedef _Tp value_type; @@ -1461,7 +1465,7 @@ private: // gslice_array template -class _LIBCPP_TYPE_VIS gslice_array +class _LIBCPP_TYPE_VIS_ONLY gslice_array { public: typedef _Tp value_type; @@ -1790,7 +1794,7 @@ gslice_array<_Tp>::operator=(const value_type& __x) const // mask_array template -class _LIBCPP_TYPE_VIS mask_array +class _LIBCPP_TYPE_VIS_ONLY mask_array { public: typedef _Tp value_type; @@ -2134,7 +2138,7 @@ public: // indirect_array template -class _LIBCPP_TYPE_VIS indirect_array +class _LIBCPP_TYPE_VIS_ONLY indirect_array { public: typedef _Tp value_type; @@ -2485,7 +2489,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_t size() const {return __1d_.size();} - template friend class _LIBCPP_TYPE_VIS valarray; + template friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template @@ -2624,7 +2628,7 @@ public: }; template -__val_expr<_ValExpr>::operator valarray() const +__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const { valarray __r; size_t __n = __expr_.size(); @@ -4770,10 +4774,6 @@ end(const valarray<_Tp>& __v) return __v.__end_; } -_LIBCPP_EXTERN_TEMPLATE(valarray::valarray(size_t)) -_LIBCPP_EXTERN_TEMPLATE(valarray::~valarray()) -_LIBCPP_EXTERN_TEMPLATE(void valarray::resize(size_t, size_t)) - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_VALARRAY diff --git a/contrib/libc++/include/vector b/contrib/libc++/include/vector index 046d92dc9..6ac78d5d5 100644 --- a/contrib/libc++/include/vector +++ b/contrib/libc++/include/vector @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible::value); explicit vector(const allocator_type&); explicit vector(size_type n); + explicit vector(size_type n, const allocator_type&); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); @@ -161,7 +162,8 @@ public: vector() noexcept(is_nothrow_default_constructible::value); explicit vector(const allocator_type&); - explicit vector(size_type n, const value_type& value = value_type(), const allocator_type& = allocator_type()); + explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 + vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); vector(const vector& x); @@ -216,8 +218,10 @@ public: const_reference back() const; void push_back(const value_type& x); + template void emplace_back(Args&&... args); // C++14 void pop_back(); + template iterator emplace(const_iterator position, Args&&... args); // C++14 iterator insert(const_iterator position, const value_type& x); iterator insert(const_iterator position, size_type n, const value_type& x); template @@ -272,6 +276,12 @@ void swap(vector& x, vector& y) #include <__undef_min_max> +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -309,14 +319,14 @@ __vector_base_common<__b>::__throw_out_of_range() const #endif } -#ifdef _MSC_VER +#ifdef _LIBCPP_MSVC #pragma warning( push ) #pragma warning( disable: 4231 ) -#endif // _MSC_VER -_LIBCPP_EXTERN_TEMPLATE(class __vector_base_common) -#ifdef _MSC_VER +#endif // _LIBCPP_MSVC +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common) +#ifdef _LIBCPP_MSVC #pragma warning( pop ) -#endif // _MSC_VER +#endif // _LIBCPP_MSVC template class __vector_base @@ -430,7 +440,7 @@ private: }; template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -439,7 +449,7 @@ __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), @@ -449,7 +459,7 @@ __vector_base<_Tp, _Allocator>::__vector_base() } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) : __begin_(nullptr), __end_(nullptr), @@ -468,7 +478,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base() } template > -class _LIBCPP_TYPE_VIS vector +class _LIBCPP_TYPE_VIS_ONLY vector : private __vector_base<_Tp, _Allocator> { private: @@ -508,15 +518,19 @@ public: #endif } explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const_reference __x); vector(size_type __n, const_reference __x, const allocator_type& __a); template - vector(_InputIterator __first, _InputIterator __last, + vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last); template vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && @@ -525,11 +539,12 @@ public: value_type, typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); template - vector(_ForwardIterator __first, _ForwardIterator __last, + vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last); template vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && @@ -882,7 +897,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { @@ -920,7 +935,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -1014,6 +1029,22 @@ vector<_Tp, _Allocator>::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template +vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) + : __base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n); + } +} +#endif + template vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) { @@ -1043,12 +1074,13 @@ vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const alloca template template -vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, +vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type*) + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1076,11 +1108,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c template template -vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, +vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type*) + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1146,7 +1179,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) : __base(_VSTD::move(__x.__alloc())) @@ -1162,7 +1195,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) { @@ -1189,7 +1222,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1203,7 +1236,7 @@ vector<_Tp, _Allocator>::vector(initializer_list __il) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) : __base(__a) { @@ -1220,7 +1253,7 @@ vector<_Tp, _Allocator>::vector(initializer_list __il, const allocat #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) _NOEXCEPT_( @@ -1264,7 +1297,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) { @@ -1353,7 +1386,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { @@ -1365,7 +1398,7 @@ vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { @@ -1377,7 +1410,7 @@ vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { @@ -1385,7 +1418,7 @@ vector<_Tp, _Allocator>::begin() _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT { @@ -1393,7 +1426,7 @@ vector<_Tp, _Allocator>::begin() const _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { @@ -1401,7 +1434,7 @@ vector<_Tp, _Allocator>::end() _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT { @@ -1409,7 +1442,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) { @@ -1418,7 +1451,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::operator[](size_type __n) const { @@ -1496,7 +1529,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) { @@ -1513,7 +1546,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -1545,7 +1578,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -1564,7 +1597,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::pop_back() { @@ -1573,7 +1606,7 @@ vector<_Tp, _Allocator>::pop_back() } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) { @@ -1983,7 +2016,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __ #endif // _LIBCPP_DEBUG_LEVEL >= 2 template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_all_iterators() { @@ -2005,7 +2038,7 @@ struct __has_storage_type > }; template -class _LIBCPP_TYPE_VIS vector +class _LIBCPP_TYPE_VIS_ONLY vector : private __vector_base_common { public: @@ -2018,21 +2051,8 @@ public: typedef size_type __storage_type; typedef __bit_iterator pointer; typedef __bit_iterator const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter iterator; - typedef __debug_iter const_iterator; - - friend class __debug_iter; - friend class __debug_iter; - - pair __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} -#else // _LIBCPP_DEBUG typedef pointer iterator; typedef const_pointer const_iterator; -#endif // _LIBCPP_DEBUG typedef _VSTD::reverse_iterator reverse_iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; @@ -2084,6 +2104,9 @@ public: _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); ~vector(); explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const value_type& __v); vector(size_type __n, const value_type& __v, const allocator_type& __a); template @@ -2215,8 +2238,20 @@ public: _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} void push_back(const value_type& __x); +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) + { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); } +#endif + _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} +#if _LIBCPP_STD_VER > 11 + template + _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) + { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } +#endif + iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const_reference __x); @@ -2261,7 +2296,7 @@ private: void allocate(size_type __n); void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - static size_type __align(size_type __new_size) _NOEXCEPT + static size_type __align_it(size_type __new_size) _NOEXCEPT {return __new_size + (__bits_per_word-1) & ~(__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); @@ -2279,14 +2314,6 @@ private: _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_type __pos) const _NOEXCEPT {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} -#ifdef _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) - {return iterator(this, pointer(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_type __pos) const - {return const_iterator(this, const_pointer(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) - {return iterator(this, pointer(const_cast<__storage_pointer>(__p.base().__seg_), __p.base().__ctz_));} -#else // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} @@ -2296,7 +2323,6 @@ private: _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} -#endif // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __v) @@ -2363,20 +2389,14 @@ private: friend class __bit_iterator; friend class __bit_iterator; friend struct __bit_array; - friend struct _LIBCPP_TYPE_VIS hash; + friend struct _LIBCPP_TYPE_VIS_ONLY hash; }; template -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void vector::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG } // Allocate space for __n objects @@ -2424,7 +2444,7 @@ vector::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector::size_type vector::__recommend(size_type __new_size) const { @@ -2434,7 +2454,7 @@ vector::__recommend(size_type __new_size) const const size_type __cap = capacity(); if (__cap >= __ms / 2) return __ms; - return _VSTD::max(2*__cap, __align(__new_size)); + return _VSTD::max(2*__cap, __align_it(__new_size)); } // Default constructs __n objects starting at __end_ @@ -2442,7 +2462,7 @@ vector::__recommend(size_type __new_size) const // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector::__construct_at_end(size_type __n, bool __x) { @@ -2466,7 +2486,7 @@ vector::__construct_at_end(_ForwardIterator __first, _ForwardI } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector::vector() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), @@ -2476,7 +2496,7 @@ vector::vector() } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector::vector(const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2497,6 +2517,21 @@ vector::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template +vector::vector(size_type __n, const allocator_type& __a) + : __begin_(nullptr), + __size_(0), + __cap_alloc_(0, static_cast<__storage_allocator>(__a)) +{ + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n, false); + } +} +#endif + template vector::vector(size_type __n, const value_type& __x) : __begin_(nullptr), @@ -2646,9 +2681,7 @@ vector::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); -#ifdef _LIBCPP_DEBUG __invalidate_all_iterators(); -#endif } template @@ -2701,7 +2734,7 @@ vector::operator=(const vector& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector::vector(vector&& __v) _NOEXCEPT_(is_nothrow_move_constructible::value) : __begin_(__v.__begin_), @@ -2735,7 +2768,7 @@ vector::vector(vector&& __v, const allocator_type& __a) } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector& vector::operator=(vector&& __v) _NOEXCEPT_( @@ -3022,7 +3055,7 @@ vector::insert(const_iterator __position, _ForwardIterator __f } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector::iterator vector::erase(const_iterator __position) { @@ -3053,10 +3086,6 @@ vector::swap(vector& __x) _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); __swap_alloc(this->__alloc(), __x.__alloc()); -#ifdef _LIBCPP_DEBUG - iterator::swap(this, &__x); - const_iterator::swap(this, &__x); -#endif // _LIBCPP_DEBUG } template @@ -3146,7 +3175,7 @@ vector::__hash_code() const _NOEXCEPT } template -struct _LIBCPP_TYPE_VIS hash > +struct _LIBCPP_TYPE_VIS_ONLY hash > : public unary_function, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -3155,7 +3184,7 @@ struct _LIBCPP_TYPE_VIS hash > }; template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3164,7 +3193,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3172,7 +3201,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3180,7 +3209,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3188,7 +3217,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3196,7 +3225,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3204,7 +3233,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/contrib/libc++/src/algorithm.cpp b/contrib/libc++/src/algorithm.cpp index 6d5cf7c0b..10c4c3312 100644 --- a/contrib/libc++/src/algorithm.cpp +++ b/contrib/libc++/src/algorithm.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #include "algorithm" #include "random" #include "mutex" diff --git a/contrib/libc++/src/debug.cpp b/contrib/libc++/src/debug.cpp index 04d570ed2..d0e867957 100644 --- a/contrib/libc++/src/debug.cpp +++ b/contrib/libc++/src/debug.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_DEBUG2 1 +#define _LIBCPP_DEBUG 1 #include "__config" #include "__debug" #include "functional" @@ -118,20 +118,19 @@ void __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); - __i_node* i = __insert_iterator(__i); - const char* errmsg = - "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"; - _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg); + if (__cbeg_ == __cend_) + return; size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; } + __i_node* i = __insert_iterator(__i); c->__add(i); i->__c_ = c; } @@ -217,18 +216,23 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A"); - while (p->__c_ != __c) - { - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all B"); - } - while (p->end_ != p->beg_) + if (__cend_ != __cbeg_) { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + while (p->__c_ != __c) + { + p = p->__next_; + if (p == nullptr) + return; + } + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } } } @@ -236,13 +240,26 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); + if (__cend_ == __cbeg_) + { + mut().unlock(); + return nullptr; + } size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } while (p->__c_ != __c) { p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } } return p; } @@ -271,28 +288,35 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - __c_node* q = nullptr; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); - while (p->__c_ != __c) + if (__cend_ != __cbeg_) { - q = p; - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); - } - if (q == nullptr) - __cbeg_[hc] = p->__next_; - else - q->__next_ = p->__next_; - while (p->end_ != p->beg_) - { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash()(__c) % static_cast(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + __c_node* q = nullptr; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); + while (p->__c_ != __c) + { + q = p; + p = p->__next_; + if (p == nullptr) + return; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); + } + if (q == nullptr) + __cbeg_[hc] = p->__next_; + else + q->__next_ = p->__next_; + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } + free(p->beg_); + free(p); + --__csz_; } - free(p->beg_); - free(p); - --__csz_; } void @@ -354,7 +378,7 @@ __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const } bool -__libcpp_db::__comparable(const void* __i, const void* __j) const +__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const { RLock _(mut()); __i_node* i = __find_iterator(__i); diff --git a/contrib/libc++/src/exception.cpp b/contrib/libc++/src/exception.cpp index 1d2f6b259..3ce6f2e11 100644 --- a/contrib/libc++/src/exception.cpp +++ b/contrib/libc++/src/exception.cpp @@ -7,8 +7,10 @@ // //===----------------------------------------------------------------------===// #include +#include #include "exception" +#include "new" #ifndef __has_include #define __has_include(inc) 0 @@ -22,7 +24,7 @@ #ifndef _LIBCPPABI_VERSION using namespace __cxxabiapple; // On Darwin, there are two STL shared libraries and a lower level ABI - // shared libray. The globals holding the current terminate handler and + // shared library. The globals holding the current terminate handler and // current unexpected handler are in the ABI library. #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler @@ -77,7 +79,7 @@ get_terminate() _NOEXCEPT return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); } -#ifndef EMSCRIPTEN // We provide this in JS +#ifndef __EMSCRIPTEN__ // We provide this in JS _LIBCPP_NORETURN void terminate() _NOEXCEPT @@ -88,31 +90,39 @@ terminate() _NOEXCEPT #endif // _LIBCPP_NO_EXCEPTIONS (*get_terminate())(); // handler should not return - ::abort (); + printf("terminate_handler unexpectedly returned\n"); + ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception - ::abort (); + printf("terminate_handler unexpectedly threw an exception\n"); + ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS } -#endif // !EMSCRIPTEN +#endif // !__EMSCRIPTEN__ #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) -#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(EMSCRIPTEN) +#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__) bool uncaught_exception() _NOEXCEPT { #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) // on Darwin, there is a helper function so __cxa_get_globals is private return __cxa_uncaught_exception(); #else // __APPLE__ - #warning uncaught_exception not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("uncaught_exception not yet implemented") +# else +# warning uncaught_exception not yet implemented +# endif + printf("uncaught_exception not yet implemented\n"); ::abort(); #endif // __APPLE__ } + #ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT @@ -139,15 +149,50 @@ const char* bad_exception::what() const _NOEXCEPT #endif +#if defined(__GLIBCXX__) + +// libsupc++ does not implement the dependent EH ABI and the functionality +// it uses to implement std::exception_ptr (which it declares as an alias of +// std::__exception_ptr::exception_ptr) is not directly exported to clients. So +// we have little choice but to hijack std::__exception_ptr::exception_ptr's +// (which fortunately has the same layout as our std::exception_ptr) copy +// constructor, assignment operator and destructor (which are part of its +// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) +// function. + +namespace __exception_ptr +{ + +struct exception_ptr +{ + void* __ptr_; + + exception_ptr(const exception_ptr&) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; +}; + +} + +_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); + +#endif exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_decrement_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT @@ -155,10 +200,18 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_increment_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + new (reinterpret_cast(this)) __exception_ptr::exception_ptr( + reinterpret_cast(other)); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT @@ -171,10 +224,19 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT __ptr_ = other.__ptr_; } return *this; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + *reinterpret_cast<__exception_ptr::exception_ptr*>(this) = + reinterpret_cast(other); + return *this; +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } nested_exception::nested_exception() _NOEXCEPT @@ -182,10 +244,14 @@ nested_exception::nested_exception() _NOEXCEPT { } +#if !defined(__GLIBCXX__) + nested_exception::~nested_exception() _NOEXCEPT { } +#endif + _LIBCPP_NORETURN void nested_exception::rethrow_nested() const @@ -195,6 +261,7 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } +#if !defined(__GLIBCXX__) exception_ptr current_exception() _NOEXCEPT { @@ -205,12 +272,19 @@ exception_ptr current_exception() _NOEXCEPT exception_ptr ptr; ptr.__ptr_ = __cxa_current_primary_exception(); return ptr; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING( "exception_ptr not yet implemented" ) +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } +#endif // !__GLIBCXX__ + _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { @@ -218,9 +292,16 @@ void rethrow_exception(exception_ptr p) __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } } // std diff --git a/contrib/libc++/src/future.cpp b/contrib/libc++/src/future.cpp index 7d9a5b5da..70919ab7d 100644 --- a/contrib/libc++/src/future.cpp +++ b/contrib/libc++/src/future.cpp @@ -26,11 +26,15 @@ __future_error_category::name() const _NOEXCEPT return "future"; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch" + string __future_error_category::message(int ev) const { switch (static_cast(ev)) { + case future_errc(0): // For backwards compatibility with C++11 (LWG 2056) case future_errc::broken_promise: return string("The associated promise has been destructed prior " "to the associated state becoming ready."); @@ -46,6 +50,8 @@ __future_error_category::message(int ev) const return string("unspecified future_errc value\n"); } +#pragma clang diagnostic pop + const error_category& future_category() _NOEXCEPT { diff --git a/contrib/libc++/src/ios.cpp b/contrib/libc++/src/ios.cpp index 732a61bb2..bbe3c072e 100644 --- a/contrib/libc++/src/ios.cpp +++ b/contrib/libc++/src/ios.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "ios" #include "streambuf" #include "istream" @@ -61,7 +63,7 @@ __iostream_category::message(int ev) const } const error_category& -iostream_category() +iostream_category() _NOEXCEPT { static __iostream_category s; return s; @@ -147,8 +149,11 @@ ios_base::getloc() const } // xalloc - +#if __has_feature(cxx_atomic) +atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0); +#else int ios_base::__xindex_ = 0; +#endif int ios_base::xalloc() diff --git a/contrib/libc++/src/iostream.cpp b/contrib/libc++/src/iostream.cpp index f413681f0..7102e4389 100644 --- a/contrib/libc++/src/iostream.cpp +++ b/contrib/libc++/src/iostream.cpp @@ -22,14 +22,14 @@ _ALIGNAS_TYPE (__stdinbuf ) static char __wcin [sizeof(__stdinbuf ) static char __wcout[sizeof(__stdoutbuf)]; _ALIGNAS_TYPE (__stdoutbuf) static char __wcerr[sizeof(__stdoutbuf)]; -_ALIGNAS_TYPE (istream) char cin [sizeof(istream)]; -_ALIGNAS_TYPE (ostream) char cout[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char cerr[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char clog[sizeof(ostream)]; -_ALIGNAS_TYPE (wistream) char wcin [sizeof(wistream)]; -_ALIGNAS_TYPE (wostream) char wcout[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wcerr[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wclog[sizeof(wostream)]; +_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]; +_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]; ios_base::Init __start_std_streams; diff --git a/contrib/libc++/src/locale.cpp b/contrib/libc++/src/locale.cpp index b15f077cf..a326323ac 100644 --- a/contrib/libc++/src/locale.cpp +++ b/contrib/libc++/src/locale.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#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__ @@ -18,23 +20,27 @@ #include "codecvt" #include "vector" #include "algorithm" -#include "algorithm" #include "typeinfo" -#include "type_traits" +#ifndef _LIBCPP_NO_EXCEPTIONS +# include "type_traits" +#endif #include "clocale" #include "cstring" #include "cwctype" #include "__sso_allocator" -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include -#else // _WIN32 +#else // _LIBCPP_MSVCRT #include -#endif // _!WIN32 +#endif // !_LIBCPP_MSVCRT #include +#include // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. +#if defined(__clang__) #pragma clang diagnostic ignored "-Wsign-conversion" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -105,6 +111,11 @@ countof(const T * const begin, const T * const end) } +#if defined(_AIX) +// Set priority to INT_MIN + 256 + 150 +# pragma priority ( -2147483242 ) +#endif + const locale::category locale::none; const locale::category locale::collate; const locale::category locale::ctype; @@ -114,14 +125,23 @@ const locale::category locale::time; const locale::category locale::messages; const locale::category locale::all; +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif class _LIBCPP_HIDDEN locale::__imp : public facet { enum {N = 28}; +#if defined(_LIBCPP_MSVC) +// FIXME: MSVC doesn't support aligned parameters by value. +// I can't get the __sso_allocator to work here +// for MSVC I think for this reason. + vector facets_; +#else vector > facets_; +#endif string name_; public: explicit __imp(size_t refs = 0); @@ -145,7 +165,9 @@ private: template void install_from(const __imp& other); }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif locale::__imp::__imp(size_t refs) : facet(refs), @@ -755,7 +777,7 @@ ctype::~ctype() bool ctype::do_is(mask m, char_type c) const { - return isascii(c) ? ctype::classic_table()[c] & m : false; + return isascii(c) ? (ctype::classic_table()[c] & m) != 0 : false; } const wchar_t* @@ -790,7 +812,7 @@ ctype::do_toupper(char_type c) const { #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? ctype::__classic_upper_table()[c] : c; #else return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c; @@ -803,7 +825,7 @@ ctype::do_toupper(char_type* low, const char_type* high) const for (; low != high; ++low) #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) *low = isascii(*low) ? ctype::__classic_upper_table()[*low] : *low; #else @@ -817,7 +839,7 @@ ctype::do_tolower(char_type c) const { #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? ctype::__classic_lower_table()[c] : c; #else return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c; @@ -830,7 +852,7 @@ ctype::do_tolower(char_type* low, const char_type* high) const for (; low != high; ++low) #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) *low = isascii(*low) ? ctype::__classic_lower_table()[*low] : *low; #else @@ -899,7 +921,7 @@ ctype::do_toupper(char_type c) const static_cast(_DefaultRuneLocale.__mapupper[static_cast(c)]) : c; #elif defined(__NetBSD__) return static_cast(__classic_upper_table()[static_cast(c)]); -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) return isascii(c) ? static_cast(__classic_upper_table()[static_cast(c)]) : c; #else @@ -916,7 +938,7 @@ ctype::do_toupper(char_type* low, const char_type* high) const static_cast(_DefaultRuneLocale.__mapupper[static_cast(*low)]) : *low; #elif defined(__NetBSD__) *low = static_cast(__classic_upper_table()[static_cast(*low)]); -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) *low = isascii(*low) ? static_cast(__classic_upper_table()[static_cast(*low)]) : *low; #else @@ -933,7 +955,7 @@ ctype::do_tolower(char_type c) const static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c; #elif defined(__NetBSD__) return static_cast(__classic_lower_table()[static_cast(c)]); -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? static_cast(__classic_lower_table()[static_cast(c)]) : c; #else @@ -949,7 +971,7 @@ ctype::do_tolower(char_type* low, const char_type* high) const *low = isascii(*low) ? static_cast(_DefaultRuneLocale.__maplower[static_cast(*low)]) : *low; #elif defined(__NetBSD__) *low = static_cast(__classic_lower_table()[static_cast(*low)]); -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low; #else *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low; @@ -990,7 +1012,7 @@ ctype::do_narrow(const char_type* low, const char_type* high, char dfault, return low; } -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ extern "C" const unsigned short ** __ctype_b_loc(); extern "C" const int ** __ctype_tolower_loc(); extern "C" const int ** __ctype_toupper_loc(); @@ -1007,16 +1029,19 @@ ctype::classic_table() _NOEXCEPT return __cloc()->__ctype_b; #elif __sun__ return __ctype_mask; -#elif defined(_WIN32) +#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) return _ctype+1; // internal ctype mask table defined in msvcrt.dll // This is assumed to be safe, which is a nonsense assumption because we're // going to end up dereferencing it later... -#elif defined(EMSCRIPTEN) +#elif defined(__EMSCRIPTEN__) return *__ctype_b_loc(); +#elif defined(_AIX) + return (const unsigned long *)__lc_ctype_ptr->obj->mask; #else // Platform not supported: abort so the person doing the port knows what to // fix # warning ctype::classic_table() is not implemented + printf("ctype::classic_table() is not implemented\n"); abort(); return NULL; #endif @@ -1047,7 +1072,7 @@ ctype::__classic_upper_table() _NOEXCEPT return _C_toupper_tab_ + 1; } -#elif defined(EMSCRIPTEN) +#elif defined(__EMSCRIPTEN__) const int* ctype::__classic_lower_table() _NOEXCEPT { @@ -1059,7 +1084,7 @@ ctype::__classic_upper_table() _NOEXCEPT { return *__ctype_toupper_loc(); } -#endif // __GLIBC__ || EMSCRIPTEN || __NETBSD__ +#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__ // template <> class ctype_byname @@ -3201,14 +3226,25 @@ __codecvt_utf8::do_out(state_type&, const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const { +#if _WIN32 + const uint16_t* _frm = reinterpret_cast(frm); + const uint16_t* _frm_end = reinterpret_cast(frm_end); + const uint16_t* _frm_nxt = _frm; +#else const uint32_t* _frm = reinterpret_cast(frm); const uint32_t* _frm_end = reinterpret_cast(frm_end); const uint32_t* _frm_nxt = _frm; +#endif uint8_t* _to = reinterpret_cast(to); uint8_t* _to_end = reinterpret_cast(to_end); uint8_t* _to_nxt = _to; +#if _WIN32 + result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, + _Maxcode_, _Mode_); +#else result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, _Maxcode_, _Mode_); +#endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -3222,11 +3258,19 @@ __codecvt_utf8::do_in(state_type&, const uint8_t* _frm = reinterpret_cast(frm); const uint8_t* _frm_end = reinterpret_cast(frm_end); const uint8_t* _frm_nxt = _frm; +#if _WIN32 + uint16_t* _to = reinterpret_cast(to); + uint16_t* _to_end = reinterpret_cast(to_end); + uint16_t* _to_nxt = _to; + result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, + _Maxcode_, _Mode_); +#else uint32_t* _to = reinterpret_cast(to); uint32_t* _to_end = reinterpret_cast(to_end); uint32_t* _to_nxt = _to; result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, _Maxcode_, _Mode_); +#endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4328,7 +4372,7 @@ __num_put_base::__format_float(char* __fmtp, const char* __len, if (__flags & ios_base::showpoint) *__fmtp++ = '#'; ios_base::fmtflags floatfield = __flags & ios_base::floatfield; - bool uppercase = __flags & ios_base::uppercase; + bool uppercase = (__flags & ios_base::uppercase) != 0; if (floatfield == (ios_base::fixed | ios_base::scientific)) specify_precision = false; else @@ -4659,9 +4703,12 @@ __time_get::~__time_get() { freelocale(__loc_); } - +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-field-initializers" +#endif +#if defined(__GNUG__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif template <> string @@ -4807,7 +4854,9 @@ __time_get_storage::__analyze(char fmt, const ctype& ct) return result; } +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-braces" +#endif template <> wstring @@ -5826,19 +5875,19 @@ moneypunct_byname::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) -#else // _WIN32 +#else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) -#endif //_WIN32 +#endif // !_LIBCPP_MSVCRT __positive_sign_ = "()"; else __positive_sign_ = lc->positive_sign; -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if(lc->n_sign_posn == 0) -#else // _WIN32 +#else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) -#endif // _WIN32 +#endif // !_LIBCPP_MSVCRT __negative_sign_ = "()"; else __negative_sign_ = lc->negative_sign; @@ -5846,19 +5895,19 @@ moneypunct_byname::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' '); __init_pat(__neg_format_, __curr_symbol_, true, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' '); -#else +#else // _LIBCPP_MSVCRT __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn, ' '); __init_pat(__neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, ' '); -#endif // _WIN32 +#endif // !_LIBCPP_MSVCRT } template<> @@ -5985,11 +6034,11 @@ moneypunct_byname::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) -#else // _WIN32 +#else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) -#endif // _WIN32 +#endif // !_LIBCPP_MSVCRT __positive_sign_ = L"()"; else { @@ -6005,11 +6054,11 @@ moneypunct_byname::init(const char* nm) wbe = wbuf + j; __positive_sign_.assign(wbuf, wbe); } -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->n_sign_posn == 0) -#else // _WIN32 +#else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) -#endif // _WIN32 +#endif // !_LIBCPP_MSVCRT __negative_sign_ = L"()"; else { @@ -6029,19 +6078,19 @@ moneypunct_byname::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' '); __init_pat(__neg_format_, __curr_symbol_, true, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' '); -#else // _WIN32 +#else // _LIBCPP_MSVCRT __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn, L' '); __init_pat(__neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, L' '); -#endif // _WIN32 +#endif // !_LIBCPP_MSVCRT } void __do_nothing(void*) {} diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp index 42195aa80..07678978a 100644 --- a/contrib/libc++/src/mutex.cpp +++ b/contrib/libc++/src/mutex.cpp @@ -42,6 +42,7 @@ void mutex::unlock() _NOEXCEPT { int ec = pthread_mutex_unlock(&__m_); + (void)ec; assert(ec == 0); } @@ -79,6 +80,7 @@ fail: recursive_mutex::~recursive_mutex() { int e = pthread_mutex_destroy(&__m_); + (void)e; assert(e == 0); } @@ -94,6 +96,7 @@ void recursive_mutex::unlock() _NOEXCEPT { int e = pthread_mutex_unlock(&__m_); + (void)e; assert(e == 0); } diff --git a/contrib/libc++/src/new.cpp b/contrib/libc++/src/new.cpp index b23a516ff..f4998cfb2 100644 --- a/contrib/libc++/src/new.cpp +++ b/contrib/libc++/src/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include #include "new" @@ -20,7 +22,7 @@ #ifndef _LIBCPPABI_VERSION // On Darwin, there are two STL shared libraries and a lower level ABI - // shared libray. The global holding the current new handler is + // shared library. The global holding the current new handler is // in the ABI library and named __cxa_new_handler. #define __new_handler __cxxabiapple::__cxa_new_handler #endif @@ -28,16 +30,18 @@ #if defined(LIBCXXRT) || __has_include() #include #endif // __has_include() - #ifndef _LIBCPPABI_VERSION + #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif +#ifndef __GLIBCXX__ + // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overriden by programs // that define non-weak copies of the functions. -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) @@ -64,7 +68,7 @@ operator new(std::size_t size) return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -83,7 +87,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) @@ -93,7 +97,7 @@ operator new[](size_t size) return ::operator new(size); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -112,7 +116,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr) _NOEXCEPT { @@ -120,34 +124,40 @@ operator delete(void* ptr) _NOEXCEPT ::free(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } +#endif // !__GLIBCXX__ + namespace std { +#ifndef __GLIBCXX__ const nothrow_t nothrow = {}; +#endif #ifndef _LIBCPPABI_VERSION +#ifndef __GLIBCXX__ + new_handler set_new_handler(new_handler handler) _NOEXCEPT { @@ -160,12 +170,16 @@ get_new_handler() _NOEXCEPT return __sync_fetch_and_add(&__new_handler, (new_handler)0); } +#endif // !__GLIBCXX__ + #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } +#ifndef __GLIBCXX__ + bad_alloc::~bad_alloc() _NOEXCEPT { } @@ -176,6 +190,8 @@ bad_alloc::what() const _NOEXCEPT return "std::bad_alloc"; } +#endif // !__GLIBCXX__ + #endif //LIBCXXRT bad_array_new_length::bad_array_new_length() _NOEXCEPT @@ -186,13 +202,29 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT { } +const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION + +#ifndef LIBSTDCXX void __throw_bad_alloc() @@ -202,4 +234,6 @@ __throw_bad_alloc() #endif } +#endif // !LIBSTDCXX + } // std diff --git a/contrib/libc++/src/optional.cpp b/contrib/libc++/src/optional.cpp new file mode 100644 index 000000000..b614d8116 --- /dev/null +++ b/contrib/libc++/src/optional.cpp @@ -0,0 +1,25 @@ +//===------------------------ optional.cpp --------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include "experimental/optional" + +namespace std // purposefully not using versioning namespace +{ namespace experimental { + +#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + +bad_optional_access::~bad_optional_access() _NOEXCEPT {} + +#else + +bad_optional_access::~bad_optional_access() _NOEXCEPT = default; + +#endif + +}} // std::experimental diff --git a/contrib/libc++/src/random.cpp b/contrib/libc++/src/random.cpp index 97a40c509..bd24f2e50 100644 --- a/contrib/libc++/src/random.cpp +++ b/contrib/libc++/src/random.cpp @@ -7,18 +7,45 @@ // //===----------------------------------------------------------------------===// +#if defined(_WIN32) +// Must be defined before including stdlib.h to enable rand_s(). +#define _CRT_RAND_S +#include +#endif + #include "random" #include "system_error" #ifdef __sun__ #define rename solaris_headers_are_broken #endif +#if !defined(_WIN32) #include #include +#endif // defined(_WIN32) #include _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_WIN32) +random_device::random_device(const string&) +{ +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + errno_t err = rand_s(&r); + if (err) + __throw_system_error(err, "random_device rand_s failed."); + return r; +} +#else random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { @@ -38,6 +65,7 @@ random_device::operator()() read(__f_, &r, sizeof(r)); return r; } +#endif // defined(_WIN32) double random_device::entropy() const _NOEXCEPT diff --git a/contrib/libc++/src/shared_mutex.cpp b/contrib/libc++/src/shared_mutex.cpp new file mode 100644 index 000000000..5fb22e445 --- /dev/null +++ b/contrib/libc++/src/shared_mutex.cpp @@ -0,0 +1,101 @@ +//===---------------------- shared_mutex.cpp ------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#define _LIBCPP_BUILDING_SHARED_MUTEX +#include "shared_mutex" + +_LIBCPP_BEGIN_NAMESPACE_STD + +shared_mutex::shared_mutex() + : __state_(0) +{ +} + +// Exclusive ownership + +void +shared_mutex::lock() +{ + unique_lock lk(__mut_); + while (__state_ & __write_entered_) + __gate1_.wait(lk); + __state_ |= __write_entered_; + while (__state_ & __n_readers_) + __gate2_.wait(lk); +} + +bool +shared_mutex::try_lock() +{ + unique_lock lk(__mut_); + if (__state_ == 0) + { + __state_ = __write_entered_; + return true; + } + return false; +} + +void +shared_mutex::unlock() +{ + lock_guard _(__mut_); + __state_ = 0; + __gate1_.notify_all(); +} + +// Shared ownership + +void +shared_mutex::lock_shared() +{ + unique_lock lk(__mut_); + while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + __gate1_.wait(lk); + unsigned num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; +} + +bool +shared_mutex::try_lock_shared() +{ + unique_lock lk(__mut_); + unsigned num_readers = __state_ & __n_readers_; + if (!(__state_ & __write_entered_) && num_readers != __n_readers_) + { + ++num_readers; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + return true; + } + return false; +} + +void +shared_mutex::unlock_shared() +{ + lock_guard _(__mut_); + unsigned num_readers = (__state_ & __n_readers_) - 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + if (__state_ & __write_entered_) + { + if (num_readers == 0) + __gate2_.notify_one(); + } + else + { + if (num_readers == __n_readers_ - 1) + __gate1_.notify_one(); + } +} + + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/src/stdexcept.cpp b/contrib/libc++/src/stdexcept.cpp index 8d25f3ee5..a4207d605 100644 --- a/contrib/libc++/src/stdexcept.cpp +++ b/contrib/libc++/src/stdexcept.cpp @@ -28,7 +28,9 @@ // Note: optimize for size +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility push(hidden) +#endif namespace { @@ -47,9 +49,9 @@ private: 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) _LIBCPP_CANTTHROW; - __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW; - ~__libcpp_nmstr() _LIBCPP_CANTTHROW; + __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_;} }; @@ -65,14 +67,14 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg) } inline -__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) +__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) +__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT { const char* p = str_; str_ = s.str_; @@ -91,7 +93,9 @@ __libcpp_nmstr::~__libcpp_nmstr() } +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility pop +#endif namespace std // purposefully not using versioning namespace { @@ -123,7 +127,7 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) logic_error::~logic_error() _NOEXCEPT { @@ -167,7 +171,7 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) runtime_error::~runtime_error() _NOEXCEPT { diff --git a/contrib/libc++/src/string.cpp b/contrib/libc++/src/string.cpp index c6fe408ca..fde52129e 100644 --- a/contrib/libc++/src/string.cpp +++ b/contrib/libc++/src/string.cpp @@ -7,15 +7,18 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "string" #include "cstdlib" #include "cwchar" #include "cerrno" #include "limits" #include "stdexcept" -#ifdef _WIN32 +#ifdef _LIBCPP_MSVCRT #include "support/win32/support.h" -#endif // _WIN32 +#endif // _LIBCPP_MSVCRT +#include _LIBCPP_BEGIN_NAMESPACE_STD @@ -38,6 +41,7 @@ void throw_helper( const string& msg ) #ifndef _LIBCPP_NO_EXCEPTIONS throw T( msg ); #else + printf("%s\n", msg.c_str()); abort(); #endif } @@ -87,7 +91,7 @@ inline int as_integer(const string& func, const string& s, size_t* idx, int base ) { - // Use long as no Stantard string to integer exists. + // Use long as no Standard string to integer exists. long r = as_integer_helper( func, s, idx, base, strtol ); if (r < numeric_limits::min() || numeric_limits::max() < r) throw_from_string_out_of_range(func); @@ -425,7 +429,7 @@ inline wide_printf get_swprintf() { -#ifndef _WIN32 +#ifndef _LIBCPP_MSVCRT return swprintf; #else return static_cast(swprintf); diff --git a/contrib/libc++/src/strstream.cpp b/contrib/libc++/src/strstream.cpp index 518422bd2..c1965ea37 100644 --- a/contrib/libc++/src/strstream.cpp +++ b/contrib/libc++/src/strstream.cpp @@ -156,13 +156,13 @@ strstreambuf::overflow(int_type __c) { if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0) return int_type(EOF); - streamsize old_size = (epptr() ? epptr() : egptr()) - eback(); - streamsize new_size = max(__alsize_, 2*old_size); + size_t old_size = static_cast ((epptr() ? epptr() : egptr()) - eback()); + size_t new_size = max(static_cast(__alsize_), 2*old_size); if (new_size == 0) new_size = __default_alsize; char* buf = nullptr; if (__palloc_) - buf = static_cast(__palloc_(static_cast(new_size))); + buf = static_cast(__palloc_(new_size)); else buf = new char[new_size]; if (buf == nullptr) @@ -229,8 +229,8 @@ strstreambuf::pos_type strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; bool legal = false; switch (__way) { @@ -287,8 +287,8 @@ strstreambuf::pos_type strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; if (pos_in || pos_out) { if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr))) diff --git a/contrib/libc++/src/system_error.cpp b/contrib/libc++/src/system_error.cpp index 7376b770e..b40409f85 100644 --- a/contrib/libc++/src/system_error.cpp +++ b/contrib/libc++/src/system_error.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" #include "string" #include "cstring" diff --git a/contrib/libc++/src/thread.cpp b/contrib/libc++/src/thread.cpp index 1fd8bb047..338a8a24c 100644 --- a/contrib/libc++/src/thread.cpp +++ b/contrib/libc++/src/thread.cpp @@ -14,9 +14,9 @@ #include "limits" #include #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) +#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) #include -#endif // !__sun__ && !__linux__ +#endif // !__sun__ && !__linux__ && !_AIX #include #endif // !_WIN32 @@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT #else // defined(CTL_HW) && defined(HW_NCPU) // TODO: grovel through /proc or check cpuid on x86 and similar // instructions on other architectures. -#warning hardware_concurrency not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("hardware_concurrency not yet implemented") +# else +# warning hardware_concurrency not yet implemented +# endif return 0; // Means not computable [thread.thread.static] #endif // defined(CTL_HW) && defined(HW_NCPU) } diff --git a/contrib/libc++/src/typeinfo.cpp b/contrib/libc++/src/typeinfo.cpp index 60828944a..b42812091 100644 --- a/contrib/libc++/src/typeinfo.cpp +++ b/contrib/libc++/src/typeinfo.cpp @@ -20,12 +20,18 @@ #include "typeinfo" -#if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT)) +#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) std::bad_cast::bad_cast() _NOEXCEPT { } +std::bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +#ifndef __GLIBCXX__ + std::bad_cast::~bad_cast() _NOEXCEPT { } @@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT return "std::bad_cast"; } -std::bad_typeid::bad_typeid() _NOEXCEPT -{ -} - std::bad_typeid::~bad_typeid() _NOEXCEPT { } @@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT } #endif -#endif // _LIBCPPABI_VERSION +#endif // !__GLIBCXX__ +#endif // !LIBCXXRT && !_LIBCPPABI_VERSION diff --git a/contrib/libc++/src/valarray.cpp b/contrib/libc++/src/valarray.cpp index 2d8db52ac..e4c9ed024 100644 --- a/contrib/libc++/src/valarray.cpp +++ b/contrib/libc++/src/valarray.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "valarray" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index 26acbe243..567aa1eb3 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -77,6 +77,8 @@ .. .. v1 + experimental + .. ext .. .. diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index d540ca29b..7690f112c 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -25,8 +25,10 @@ SRCS+= algorithm.cpp\ memory.cpp\ mutex.cpp\ new.cpp\ + optional.cpp\ random.cpp\ regex.cpp\ + shared_mutex.cpp\ stdexcept.cpp\ string.cpp\ strstream.cpp\ @@ -61,7 +63,7 @@ CXXFLAGS+= -std=c++0x DPADD= ${LIBCXXRT} LDADD= -lcxxrt LDFLAGS+= --verbose -INCSGROUPS= STD EXT +INCSGROUPS= STD EXP EXT STD_HEADERS= __bit_reference\ __config\ @@ -140,6 +142,7 @@ STD_HEADERS= __bit_reference\ regex\ scoped_allocator\ set\ + shared_mutex\ sstream\ stack\ stdexcept\ @@ -171,6 +174,14 @@ STD+= ${LIBCXXRTDIR}/${hdr} .endfor STDDIR= ${CXXINCLUDEDIR} +EXP_HEADERS= dynarray\ + optional + +.for hdr in ${EXP_HEADERS} +EXP+= ${HDRDIR}/experimental/${hdr} +.endfor +EXPDIR= ${CXXINCLUDEDIR}/experimental + EXT_HEADERS= __hash\ hash_map\ hash_set diff --git a/sys/sys/param.h b/sys/sys/param.h index 0ee9cf97e..f92e6b885 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 902506 /* Master, propagated to newvers */ +#define __FreeBSD_version 902507 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index bf6b7ce93..3f9f7ebd2 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -2822,6 +2822,8 @@ OLD_FILES+=usr/include/c++/v1/cwctype OLD_FILES+=usr/include/c++/v1/cxxabi.h OLD_FILES+=usr/include/c++/v1/deque OLD_FILES+=usr/include/c++/v1/exception +OLD_FILES+=usr/include/c++/v1/experimental/dynarray +OLD_FILES+=usr/include/c++/v1/experimental/optional OLD_FILES+=usr/include/c++/v1/ext/__hash OLD_FILES+=usr/include/c++/v1/ext/hash_map OLD_FILES+=usr/include/c++/v1/ext/hash_set @@ -2872,6 +2874,7 @@ OLD_FILES+=usr/include/c++/v1/unwind.h OLD_FILES+=usr/include/c++/v1/utility OLD_FILES+=usr/include/c++/v1/valarray OLD_FILES+=usr/include/c++/v1/vector +OLD_DIRS+=usr/include/c++/v1/experimental OLD_DIRS+=usr/include/c++/v1/ext OLD_DIRS+=usr/include/c++/v1 .endif -- 2.45.0