diff --git a/Makefile.inc1 b/Makefile.inc1 index b68a0d82c54a..c949987a49ec 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -500,7 +500,7 @@ HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q} HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT .endif -CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \ +CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \ CPP="${XCPP} ${XCFLAGS}" \ AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \ OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \ diff --git a/contrib/libc++/include/__config b/contrib/libc++/include/__config index fe9eec4d097f..e574bf0fdc22 100644 --- a/contrib/libc++/include/__config +++ b/contrib/libc++/include/__config @@ -11,19 +11,37 @@ #ifndef _LIBCPP_CONFIG #define _LIBCPP_CONFIG -#if !defined(_MSC_VER) || defined(__clang__) +#if defined(_MSC_VER) && !defined(__clang__) +#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#endif + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif +#ifdef __cplusplus + #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #else #define _GNUC_VER 0 #endif -#define _LIBCPP_VERSION 3700 +#define _LIBCPP_VERSION 3800 +#ifndef _LIBCPP_ABI_VERSION #define _LIBCPP_ABI_VERSION 1 +#endif + +#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 +// Change short string represention so that string data starts at offset 0, +// improving its alignment in some cases. +#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +// Fix deque iterator type in order to support incomplete types. +#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +// Fix undefined behavior in how std::list stores it's linked nodes. +#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB +#endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) @@ -37,6 +55,9 @@ #ifndef __has_builtin #define __has_builtin(__x) 0 #endif +#ifndef __has_extension +#define __has_extension(__x) 0 +#endif #ifndef __has_feature #define __has_feature(__x) 0 #endif @@ -61,6 +82,16 @@ #endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ +#ifdef __BYTE_ORDER__ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define _LIBCPP_LITTLE_ENDIAN 1 +#define _LIBCPP_BIG_ENDIAN 0 +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define _LIBCPP_LITTLE_ENDIAN 0 +#define _LIBCPP_BIG_ENDIAN 1 +#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#endif // __BYTE_ORDER__ + #ifdef __FreeBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN @@ -227,9 +258,12 @@ #if defined(__clang__) -#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - !defined(__arm__) -#define _LIBCPP_ALTERNATE_STRING_LAYOUT +// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for +// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. +#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ + !defined(__arm__)) || \ + defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) +#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #endif #if __has_feature(cxx_alignas) @@ -273,6 +307,10 @@ typedef __char32_t char32_t; #define _LIBCPP_UNUSED __attribute__((__unused__)) +#if !(__has_feature(cxx_default_function_template_args)) +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS +#endif + #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) @@ -354,14 +392,19 @@ typedef __char32_t char32_t; #elif defined(__ANDROID__) #define _LIBCPP_HAS_QUICK_EXIT #elif defined(__linux__) -#include +#if !defined(_LIBCPP_HAS_MUSL_LIBC) +# include #if __GLIBC_PREREQ(2, 15) #define _LIBCPP_HAS_QUICK_EXIT #endif #if __GLIBC_PREREQ(2, 17) #define _LIBCPP_HAS_C11_FEATURES #endif +#else // defined(_LIBCPP_HAS_MUSL_LIBC) +#define _LIBCPP_HAS_QUICK_EXIT +#define _LIBCPP_HAS_C11_FEATURES #endif +#endif // __linux__ #endif #if !(__has_feature(cxx_noexcept)) @@ -390,6 +433,11 @@ namespace std { #define _LIBCPP_HAS_NO_ASAN #endif +// Allow for build-time disabling of unsigned integer sanitization +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned-integer-overflow"))) +#endif + #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -437,6 +485,7 @@ namespace std { #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NULLPTR @@ -444,22 +493,18 @@ namespace std { #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_HAS_NO_NOEXCEPT #else // __GXX_EXPERIMENTAL_CXX0X__ -#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS - #if _GNUC_VER < 403 +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - -#if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif + #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS @@ -498,7 +543,6 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #elif defined(_LIBCPP_MSVC) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES -#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES @@ -532,9 +576,9 @@ namespace std { #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_UNUSED +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #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_NOEXCEPT #define _LIBCPP_HAS_NO_NULLPTR @@ -579,9 +623,11 @@ typedef unsigned int char32_t; #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT +extern "C++" { template struct __static_assert_test; template <> struct __static_assert_test {}; template struct __static_assert_check {}; +} #define static_assert(__b, __m) \ typedef __static_assert_check)> \ _LIBCPP_CONCAT(__t, __LINE__) @@ -724,6 +770,12 @@ template struct __static_assert_check {}; #define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif +#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES +# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) +#else +# define _LIBCPP_EXPLICIT_MOVE(x) (x) +#endif + #ifndef _LIBCPP_HAS_NO_ASAN extern "C" void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); @@ -733,7 +785,7 @@ extern "C" void __sanitizer_annotate_contiguous_container( // 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__ >= 5) || (__GNUC__ == 4 && \ +# if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) @@ -765,7 +817,7 @@ extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_STDOUT #endif -#if defined(__ANDROID__) || defined(__CloudABI__) +#if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif @@ -775,4 +827,21 @@ extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #endif -#endif // _LIBCPP_CONFIG +#if __has_feature(cxx_atomic) || __has_extension(c_atomic) +#define _LIBCPP_HAS_C_ATOMIC_IMP +#elif _GNUC_VER > 407 +#define _LIBCPP_HAS_GCC_ATOMIC_IMP +#endif + +#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ + || defined(_LIBCPP_HAS_NO_THREADS) +#define _LIBCPP_HAS_NO_ATOMIC_HEADER +#endif + +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_CONFIG diff --git a/contrib/libc++/include/__functional_03 b/contrib/libc++/include/__functional_03 index 13c38d8548d9..4edbb0996ca0 100644 --- a/contrib/libc++/include/__functional_03 +++ b/contrib/libc++/include/__functional_03 @@ -17,218 +17,7 @@ #pragma GCC system_header #endif -template -class __mem_fn - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type __f_; - -public: - _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} - - // invoke - - typename __invoke_return::type - operator() () const - { - return __invoke(__f_); - } - - template - typename __invoke_return0::type - operator() (_A0& __a0) const - { - return __invoke(__f_, __a0); - } - - template - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const - { - return __invoke(__f_, __a0, __a1); - } - - template - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const - { - return __invoke(__f_, __a0, __a1, __a2); - } -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp _Tp::*> -mem_fn(_Rp _Tp::* __pm) -{ - return __mem_fn<_Rp _Tp::*>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)()> -mem_fn(_Rp (_Tp::* __pm)()) -{ - return __mem_fn<_Rp (_Tp::*)()>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0)> -mem_fn(_Rp (_Tp::* __pm)(_A0)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1)> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() const> -mem_fn(_Rp (_Tp::* __pm)() const) -{ - return __mem_fn<_Rp (_Tp::*)() const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) const> -mem_fn(_Rp (_Tp::* __pm)(_A0) const) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) const> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__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) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() volatile> -mem_fn(_Rp (_Tp::* __pm)() volatile) -{ - return __mem_fn<_Rp (_Tp::*)() volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__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) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() const volatile> -mem_fn(_Rp (_Tp::* __pm)() const volatile) -{ - return __mem_fn<_Rp (_Tp::*)() const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__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) const volatile>(__pm); -} - -// bad_function_call - -class _LIBCPP_EXCEPTION_ABI bad_function_call - : public exception -{ -}; - -template class _LIBCPP_TYPE_VIS_ONLY function; // undefined - -namespace __function -{ - -template -struct __maybe_derive_from_unary_function -{ -}; - -template -struct __maybe_derive_from_unary_function<_Rp(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __maybe_derive_from_binary_function -{ -}; - -template -struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; +namespace __function { template class __base; @@ -662,15 +451,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)()) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2()>& __p) {return __p;} public: typedef _Rp result_type; @@ -769,7 +549,7 @@ function<_Rp()>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -796,7 +576,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp()> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -947,27 +727,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)()) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1066,7 +825,7 @@ function<_Rp(_A0)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1093,7 +852,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1244,27 +1003,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0, _B1)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1363,7 +1101,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1390,7 +1128,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1540,27 +1278,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0, _B1, _B2)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1660,7 +1377,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1687,7 +1404,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1856,274 +1573,4 @@ void swap(function<_Fp>& __x, function<_Fp>& __y) {return __x.swap(__y);} -template struct __is_bind_expression : public false_type {}; -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_ONLY is_placeholder - : public __is_placeholder::type> {}; - -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; - -} // placeholders - -template -struct __is_placeholder > - : public integral_constant {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp& -__mu(reference_wrapper<_Tp> __t, _Uj&) -{ - return __t.get(); -} -/* -template -struct __mu_return1 {}; - -template -struct __mu_return1 -{ - typedef typename result_of<_Ti(_Uj...)>::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __mu_return1::type -__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>) -{ - __ti(_VSTD::forward::type>(_VSTD::get<_Indx>(__uj))...); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_bind_expression<_Ti>::value, - typename __mu_return1::value, _Ti, _Uj...>::type ->::type -__mu(_Ti& __ti, tuple<_Uj...>& __uj) -{ - typedef typename __make_tuple_indices::type __indices; - return __mu_expand(__ti, __uj, __indices()); -} - -template -struct __mu_return2 {}; - -template -struct __mu_return2 -{ - typedef typename tuple_element::value - 1, _Uj>::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - 0 < is_placeholder<_Ti>::value, - typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type ->::type -__mu(_Ti&, _Uj& __uj) -{ - const size_t _Indx = is_placeholder<_Ti>::value - 1; - // compiler bug workaround - typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj); - return __t; -// return _VSTD::forward::type>(_VSTD::get<_Indx>(__uj)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_bind_expression<_Ti>::value && - is_placeholder<_Ti>::value == 0 && - !__is_reference_wrapper<_Ti>::value, - _Ti& ->::type -__mu(_Ti& __ti, _Uj& __uj) -{ - return __ti; -} - -template -struct ____mu_return; - -template -struct ____mu_return<_Ti, true, false, tuple<_Uj...> > -{ - typedef typename result_of<_Ti(_Uj...)>::type type; -}; - -template -struct ____mu_return<_Ti, false, true, _TupleUj> -{ - typedef typename tuple_element::value - 1, - _TupleUj>::type&& type; -}; - -template -struct ____mu_return<_Ti, false, false, _TupleUj> -{ - typedef _Ti& type; -}; - -template -struct __mu_return - : public ____mu_return<_Ti, - is_bind_expression<_Ti>::value, - 0 < is_placeholder<_Ti>::value, - _TupleUj> -{ -}; - -template -struct __mu_return, _TupleUj> -{ - typedef _Ti& type; -}; - -template -struct __bind_return; - -template -struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> -{ - typedef typename __ref_return - < - _Fp&, - typename __mu_return - < - _BoundArgs, - _TupleUj - >::type... - >::type type; -}; - -template -struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> -{ - typedef typename __ref_return - < - _Fp&, - typename __mu_return - < - const _BoundArgs, - _TupleUj - >::type... - >::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __bind_return<_Fp, _BoundArgs, _Args>::type -__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, - _Args&& __args) -{ - return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); -} - -template -class __bind -{ - _Fp __f_; - tuple<_BoundArgs...> __bound_args_; - - typedef typename __make_tuple_indices::type __indices; -public: - template - explicit __bind(_Gp&& __f, _BA&& ...__bound_args) - : __f_(_VSTD::forward<_Gp>(__f)), - __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} - - template - typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type - operator()(_Args&& ...__args) - { - // compiler bug workaround - return __apply_functor(__f_, __bound_args_, __indices(), - tuple<_Args&&...>(__args...)); - } - - template - typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type - operator()(_Args&& ...__args) const - { - return __apply_functor(__f_, __bound_args_, __indices(), - tuple<_Args&&...>(__args...)); - } -}; - -template -struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; - -template -class __bind_r - : public __bind<_Fp, _BoundArgs...> -{ - typedef __bind<_Fp, _BoundArgs...> base; -public: - typedef _Rp result_type; - - template - explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) - : base(_VSTD::forward<_Gp>(__f), - _VSTD::forward<_BA>(__bound_args)...) {} - - template - result_type - operator()(_Args&& ...__args) - { - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); - } - - template - result_type - operator()(_Args&& ...__args) const - { - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); - } -}; - -template -struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -__bind::type, typename decay<_BoundArgs>::type...> -bind(_Fp&& __f, _BoundArgs&&... __bound_args) -{ - typedef __bind::type, typename decay<_BoundArgs>::type...> type; - return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> -bind(_Fp&& __f, _BoundArgs&&... __bound_args) -{ - typedef __bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type; - return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); -} -*/ - #endif // _LIBCPP_FUNCTIONAL_03 diff --git a/contrib/libc++/include/__functional_base b/contrib/libc++/include/__functional_base index 09424bc025a9..52c535aa3ea1 100644 --- a/contrib/libc++/include/__functional_base +++ b/contrib/libc++/include/__functional_base @@ -77,62 +77,6 @@ struct _LIBCPP_TYPE_VIS_ONLY less }; #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> - -#else // _LIBCPP_HAS_NO_VARIADICS - // __weak_result_type template @@ -314,6 +258,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> { }; + +#ifndef _LIBCPP_HAS_NO_VARIADICS // 3 or more arguments template @@ -358,8 +304,12 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> typedef _Rp result_type; }; +#endif // _LIBCPP_HAS_NO_VARIADICS + // __invoke +#ifndef _LIBCPP_HAS_NO_VARIADICS + // bullets 1 and 2 template (__f)(_VSTD::forward<_Args>(__args)...); } - template struct __invoke_return { typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; }; +#else // _LIBCPP_HAS_NO_VARIADICS + +#include <__functional_base_03> + +#endif // _LIBCPP_HAS_NO_VARIADICS + + template struct __invoke_void_return_wrapper { +#ifndef _LIBCPP_HAS_NO_VARIADICS template - static _Ret __call(_Args&&... __args) - { + static _Ret __call(_Args&&... __args) { return __invoke(_VSTD::forward<_Args>(__args)...); } +#else + template + static _Ret __call(_Fn __f) { + return __invoke(__f); + } + + template + static _Ret __call(_Fn __f, _A0& __a0) { + return __invoke(__f, __a0); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { + return __invoke(__f, __a0, __a1); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ + return __invoke(__f, __a0, __a1, __a2); + } +#endif }; template <> struct __invoke_void_return_wrapper { +#ifndef _LIBCPP_HAS_NO_VARIADICS template - static void __call(_Args&&... __args) - { + static void __call(_Args&&... __args) { __invoke(_VSTD::forward<_Args>(__args)...); } +#else + template + static void __call(_Fn __f) { + __invoke(__f); + } + + template + static void __call(_Fn __f, _A0& __a0) { + __invoke(__f, __a0); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1) { + __invoke(__f, __a0, __a1); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { + __invoke(__f, __a0, __a1, __a2); + } +#endif }; template @@ -463,14 +461,120 @@ public: _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;} _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;} +#ifndef _LIBCPP_HAS_NO_VARIADICS // invoke template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const - { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_of::type + operator() (_ArgTypes&&... __args) const { + return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); + } +#else + + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return::type + operator() () const { + return __invoke(get()); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return __invoke(get(), __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return __invoke(get(), __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } +#endif // _LIBCPP_HAS_NO_VARIADICS }; template struct __is_reference_wrapper_impl : public false_type {}; @@ -510,6 +614,7 @@ cref(reference_wrapper<_Tp> __t) _NOEXCEPT return cref(__t.get()); } +#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS diff --git a/contrib/libc++/include/__functional_base_03 b/contrib/libc++/include/__functional_base_03 index 655027786665..8407dcfa39ca 100644 --- a/contrib/libc++/include/__functional_base_03 +++ b/contrib/libc++/include/__functional_base_03 @@ -13,943 +13,166 @@ // manual variadic expansion for -// __weak_result_type - -template -struct __derives_from_unary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static unary_function<_Ap, _Rp> - __test(const volatile unary_function<_Ap, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template -struct __derives_from_binary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static binary_function<_A1, _A2, _Rp> - __test(const volatile binary_function<_A1, _A2, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template ::value> -struct __maybe_derive_from_unary_function // bool is true - : public __derives_from_unary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_unary_function<_Tp, false> -{ -}; - -template ::value> -struct __maybe_derive_from_binary_function // bool is true - : public __derives_from_binary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_binary_function<_Tp, false> -{ -}; - -template ::value> -struct __weak_result_type_imp // bool is true - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ - typedef typename _Tp::result_type result_type; -}; - -template -struct __weak_result_type_imp<_Tp, false> - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ -}; - -template -struct __weak_result_type - : public __weak_result_type_imp::type> -{ -}; - -// 0 argument case - -template -struct __weak_result_type<_Rp ()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)()> -{ - typedef _Rp result_type; -}; - -// 1 argument case - -template -struct __weak_result_type<_Rp (_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)()> - : public unary_function<_Cp*, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() volatile> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const volatile> - : public unary_function -{ -}; - -// 2 argument case - -template -struct __weak_result_type<_Rp (_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1)> - : public binary_function<_Cp*, _A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> - : public binary_function -{ -}; - -// 3 or more arguments - -template -struct __weak_result_type<_Rp (_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) const> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) volatile> -{ - typedef _Rp result_type; -}; - // __invoke -// __ref_return0 -// -// template -// struct ________ref_return0 // _HasResultType is true -// { -// typedef typename _Tp::result_type type; -// }; -// -// template -// struct ________ref_return0<_Tp, false> -// { -// typedef void type; -// }; -// -// template -// struct ____ref_return0 // _IsClass is true -// : public ________ref_return0<_Tp, __has_result_type::type>::value> -// { -// }; -// -// template -// struct ______ref_return0 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return0<_Tp, false> // pointer to member data -// { -// typedef void type; -// }; -// -// template -// struct ____ref_return0<_Tp, false> -// : public ______ref_return0::type, -// __has_result_type<__callable_type::type> >::value> -// { -// }; -// -// template -// struct __ref_return0 -// : public ____ref_return0::type, -// is_class::type>::value> -// { -// }; -// -// __ref_return1 -// -// template -// struct ____ref_return1 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0)>::type type; -// }; -// -// template -// struct ______ref_return1 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct __ref_return1_member_data1; -// -// template -// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, true> -// { -// typedef typename __apply_cv<_A0, _Rp>::type& type; -// }; -// -// template -// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, false> -// { -// static _A0 __a; -// typedef typename __apply_cv::type& type; -// }; -// -// template -// struct __ref_return1_member_data; -// -// template -// struct __ref_return1_member_data<_Rp _Cp::*, _A0> -// : public __ref_return1_member_data1<_Rp _Cp::*, _A0, -// is_same::type, -// typename remove_cv::type>::type>::value> -// { -// }; -// -// template -// struct ______ref_return1<_Tp, false, _A0> // pointer to member data -// : public __ref_return1_member_data::type, _A0> -// { -// }; -// -// template -// struct ____ref_return1<_Tp, false, _A0> -// : public ______ref_return1::type, -// __has_result_type<__callable_type::type> >::value, _A0> -// { -// }; -// -// template -// struct __ref_return1 -// : public ____ref_return1::type, -// is_class::type>::value, _A0> -// { -// }; -// -// __ref_return2 -// -// template -// struct ____ref_return2 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0, _A1)>::type type; -// }; -// -// template -// struct ______ref_return2 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return2<_Tp, false, class _A0, class _A1> // pointer to member data -// { -// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer" -// " to member data with too many arguments."); -// }; -// -// template -// struct ____ref_return2<_Tp, false, _A0, _A1> -// : public ______ref_return2::type, -// __has_result_type<__callable_type::type> >::value, _A0, _A1> -// { -// }; -// -// template -// struct __ref_return2 -// : public ____ref_return2::type, -// is_class::type>::value, _A0, _A1> -// { -// }; -// -// __ref_return3 -// -// template -// struct ____ref_return3 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0, _A1, _A2)>::type type; -// }; -// -// template -// struct ______ref_return3 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return3<_Tp, false, class _A0, class _A1, class _A2> // pointer to member data -// { -// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer" -// " to member data with too many arguments."); -// }; -// -// template -// struct ____ref_return3<_Tp, false, _A0, _A1, _A2> -// : public ______ref_return3::type, -// __has_result_type<__callable_type::type> >::value, _A0, _A1, _A2> -// { -// }; -// -// template -// struct __ref_return3 -// : public ____ref_return3::type, -// is_class::type>::value, _A0, _A1, _A2> -// { -// }; +template +struct __enable_invoke_imp; + +template +struct __enable_invoke_imp<_Ret, _T1, true, true> { + typedef _Ret _Bullet1; + typedef _Bullet1 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, true, false> { + typedef _Ret _Bullet2; + typedef _Bullet2 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, true> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet3; + typedef _Bullet3 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv()), _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1*, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template , + class _Ret = typename _Traits::_ReturnType, + class _Class = typename _Traits::_ClassType> +struct __enable_invoke : __enable_invoke_imp< + _Ret, _T1, + is_member_function_pointer<_Fn>::value, + is_base_of<_Class, typename remove_reference<_T1>::type>::value> +{ +}; + +__nat __invoke(__any, ...); // first bullet -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1) { return (__t1.*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1& __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return (__t1.*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1& __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return (__t1.*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return (__t1.*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -// second bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1 __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1) { return ((*__t1).*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1 __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return ((*__t1).*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1 __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return ((*__t1).*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return ((*__t1).*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -// third bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - typename __apply_cv<_T1, _Rp>::type& ->::type -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet3 +__invoke(_Fn __f, _T1& __t1) { return __t1.*__f; } -template +template inline _LIBCPP_INLINE_VISIBILITY -void -__invoke(_Rp _Tp::*) -{ -} - -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// is_base_of<_Tp, typename remove_reference<_T1>::type>::value, -// typename __ref_return1<_Rp _Tp::*, _T1>::type -// >::type -// __invoke(_Rp _Tp::* __f, _T1& __t1) -// { -// return __t1.*__f; -// } - -// forth bullet - -template -struct __4th_helper -{ -}; - -template -struct __4th_helper<_T1, _Rp, true> -{ - typedef typename __apply_cv()), _Rp>::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __4th_helper<_T1, _Rp, - !is_base_of<_Tp, - typename remove_reference<_T1>::type - >::value - >::type& -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet4 +__invoke(_Fn __f, _T1& __t1) { return (*__t1).*__f; } -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, -// typename __ref_return1<_Rp _Tp::*, _T1>::type -// >::type -// __invoke(_Rp _Tp::* __f, _T1 __t1) -// { -// return (*__t1).*__f; -// } - // fifth bullet template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()()) -__invoke(_Fp __f) +decltype(_VSTD::declval<_Fp&>()()) +__invoke(_Fp& __f) { return __f(); } template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()(declval<_A0&>())) -__invoke(_Fp __f, _A0& __a0) +decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>())) +__invoke(_Fp& __f, _A0& __a0) { return __f(__a0); } template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>())) -__invoke(_Fp __f, _A0& __a0, _A1& __a1) +decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>())) +__invoke(_Fp& __f, _A0& __a0, _A1& __a1) { return __f(__a0, __a1); } template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>())) -__invoke(_Fp __f, _A0& __a0, _A1& __a1, _A2& __a2) +decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>())) +__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) { return __f(__a0, __a1, __a2); } -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f) -// { -// return __f(); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// !is_member_pointer<_Fp>::value, -// _Rp -// >::type -// __invoke(_Fp& __f, _A0& __a0) -// { -// return __f(__a0); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f, _A0& __a0, _A1& __a1) -// { -// return __f(__a0, __a1); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) -// { -// return __f(__a0, __a1, __a2); -// } - -template -struct __has_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - template >::value> struct __invoke_return { @@ -959,186 +182,43 @@ struct __invoke_return template struct __invoke_return<_Fp, false> { - typedef decltype(__invoke(_VSTD::declval<_Fp>())) type; + typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type; }; template struct __invoke_return0 { - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type; }; template struct __invoke_return0<_Rp _Tp::*, _A0> { - typedef typename __apply_cv<_A0, _Rp>::type& type; -}; - -template -struct __invoke_return0<_Rp _Tp::*, _A0*> -{ - typedef typename __apply_cv<_A0, _Rp>::type& type; + typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; }; template struct __invoke_return1 { - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(), - _VSTD::declval<_A1>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), + _VSTD::declval<_A1&>())) type; +}; + +template +struct __invoke_return1<_Rp _Class::*, _A0, _A1> { + typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; }; template struct __invoke_return2 { - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(), - _VSTD::declval<_A1>(), - _VSTD::declval<_A2>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), + _VSTD::declval<_A1&>(), + _VSTD::declval<_A2&>())) type; }; -template -struct __invoke_void_return_wrapper -{ - template - static _Ret __call(_Fn __f) - { - return __invoke(__f); - } - - template - static _Ret __call(_Fn __f, _A0& __a0) - { - return __invoke(__f, __a0); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) - { - return __invoke(__f, __a0, __a1); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) - { - return __invoke(__f, __a0, __a1, __a2); - } +template +struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { + typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; }; - - -template <> -struct __invoke_void_return_wrapper -{ - template - static void __call(_Fn __f) - { - __invoke(__f); - } - - template - static void __call(_Fn __f, _A0& __a0) - { - __invoke(__f, __a0); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1) - { - __invoke(__f, __a0, __a1); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) - { - __invoke(__f, __a0, __a1, __a2); - } -}; - -template -class _LIBCPP_TYPE_VIS_ONLY reference_wrapper - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type* __f_; - -public: - // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) : __f_(&__f) {} - - // access - _LIBCPP_INLINE_VISIBILITY operator type& () const {return *__f_;} - _LIBCPP_INLINE_VISIBILITY type& get() const {return *__f_;} - - // invoke - - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() () const - { - return __invoke(get()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0& __a0) const - { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const - { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const - { - return __invoke(get(), __a0, __a1, __a2); - } -}; - -template struct __is_reference_wrapper_impl : public false_type {}; -template struct __is_reference_wrapper_impl > : public true_type {}; -template struct __is_reference_wrapper - : public __is_reference_wrapper_impl::type> {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(_Tp& __t) -{ - return reference_wrapper<_Tp>(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(reference_wrapper<_Tp> __t) -{ - return ref(__t.get()); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(const _Tp& __t) -{ - return reference_wrapper(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(reference_wrapper<_Tp> __t) -{ - return cref(__t.get()); -} - #endif // _LIBCPP_FUNCTIONAL_BASE_03 diff --git a/contrib/libc++/include/__hash_table b/contrib/libc++/include/__hash_table index ec20e10fcb57..c7d1ef3d082f 100644 --- a/contrib/libc++/include/__hash_table +++ b/contrib/libc++/include/__hash_table @@ -46,12 +46,7 @@ template struct __hash_node : public __hash_node_base < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__hash_node<_Tp, _VoidPtr> > -#else - rebind<__hash_node<_Tp, _VoidPtr> >::other -#endif + typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type > { typedef _Tp value_type; @@ -98,13 +93,7 @@ public: typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -229,20 +218,8 @@ public: typedef typename __node::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef const value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__node> -#else - rebind<__node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type pointer; + typedef typename __rebind_pointer<__node_pointer, __node>::type __non_const_node_pointer; typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator; _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT @@ -376,13 +353,7 @@ public: typedef typename __pointer_traits::element_type::value_type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT { @@ -514,13 +485,9 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator typedef pointer_traits<__node_pointer> __pointer_traits; typedef typename __pointer_traits::element_type __node; typedef typename remove_const<__node>::type __non_const_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__non_const_node> -#else - rebind<__non_const_node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type + __non_const_node_pointer; + typedef __hash_local_iterator<__non_const_node_pointer> __non_const_iterator; public: @@ -530,13 +497,9 @@ public: >::type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type + pointer; + _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT { @@ -780,13 +743,8 @@ public: typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; typedef __hash_node_base<__node_pointer> __first_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__first_node> -#else - rebind<__first_node>::other -#endif - __node_base_pointer; + typedef typename __rebind_pointer<__node_pointer, __first_node>::type + __node_base_pointer; private: @@ -836,6 +794,7 @@ public: typedef __hash_local_iterator<__node_pointer> local_iterator; typedef __hash_const_local_iterator<__node_pointer> const_local_iterator; + _LIBCPP_INLINE_VISIBILITY __hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && @@ -843,6 +802,7 @@ public: is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY __hash_table(const hasher& __hf, const key_equal& __eql); __hash_table(const hasher& __hf, const key_equal& __eql, const allocator_type& __a); @@ -863,6 +823,7 @@ public: __hash_table& operator=(const __hash_table& __u); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __hash_table& operator=(__hash_table&& __u) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && @@ -934,9 +895,13 @@ public: return __bucket_list_.get_deleter().size(); } + _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; template @@ -965,6 +930,7 @@ public: __node_holder remove(const_iterator __p) _NOEXCEPT; template + _LIBCPP_INLINE_VISIBILITY size_type __count_unique(const _Key& __k) const; template size_type __count_multi(const _Key& __k) const; @@ -1130,11 +1096,12 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && is_nothrow_default_constructible<__first_node>::value && + is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : __p2_(0), @@ -1143,7 +1110,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() } template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql) : __bucket_list_(nullptr, __bucket_list_deleter()), @@ -1203,6 +1170,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( is_nothrow_move_constructible<__bucket_list>::value && is_nothrow_move_constructible<__first_node>::value && + is_nothrow_move_constructible<__node_allocator>::value && is_nothrow_move_constructible::value && is_nothrow_move_constructible::value) : __bucket_list_(_VSTD::move(__u.__bucket_list_)), @@ -1410,7 +1378,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( } template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) _NOEXCEPT_( @@ -1495,7 +1463,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { @@ -1507,7 +1475,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { @@ -1519,7 +1487,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { @@ -1531,7 +1499,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { @@ -2108,7 +2076,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2124,7 +2092,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template @@ -2256,7 +2224,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const { diff --git a/contrib/libc++/include/__locale b/contrib/libc++/include/__locale index 19895582cac8..7bc701dda6e3 100644 --- a/contrib/libc++/include/__locale +++ b/contrib/libc++/include/__locale @@ -37,6 +37,8 @@ #elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) # include +#elif defined(_LIBCPP_HAS_MUSL_LIBC) +# include #endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -329,7 +331,7 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, class _LIBCPP_TYPE_VIS ctype_base { public: -#ifdef __GLIBC__ +#if defined(__GLIBC__) typedef unsigned short mask; static const mask space = _ISspace; static const mask print = _ISprint; @@ -359,7 +361,7 @@ public: 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; diff --git a/contrib/libc++/include/__mutex_base b/contrib/libc++/include/__mutex_base index d5ece7c1454c..b019b4760d18 100644 --- a/contrib/libc++/include/__mutex_base +++ b/contrib/libc++/include/__mutex_base @@ -14,7 +14,9 @@ #include <__config> #include #include +#ifndef _LIBCPP_HAS_NO_THREADS #include +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -306,6 +308,7 @@ public: template bool + _LIBCPP_INLINE_VISIBILITY wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); @@ -390,7 +393,7 @@ condition_variable::wait_for(unique_lock& __lk, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable::wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, diff --git a/contrib/libc++/include/__nullptr b/contrib/libc++/include/__nullptr new file mode 100644 index 000000000000..95415a6325a3 --- /dev/null +++ b/contrib/libc++/include/__nullptr @@ -0,0 +1,66 @@ +// -*- C++ -*- +//===--------------------------- __nullptr --------------------------------===// +// +// 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_NULLPTR +#define _LIBCPP_NULLPTR + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#ifdef _LIBCPP_HAS_NO_NULLPTR + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct _LIBCPP_TYPE_VIS_ONLY nullptr_t +{ + void* __lx; + + struct __nat {int __for_bool_;}; + + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} + + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} + + template + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR + operator _Tp* () const {return 0;} + + template + _LIBCPP_ALWAYS_INLINE + operator _Tp _Up::* () const {return 0;} + + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} +}; + +inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} + +#define nullptr _VSTD::__get_nullptr_t() + +_LIBCPP_END_NAMESPACE_STD + +#else // _LIBCPP_HAS_NO_NULLPTR + +namespace std +{ + typedef decltype(nullptr) nullptr_t; +} + +#endif // _LIBCPP_HAS_NO_NULLPTR + +#endif // _LIBCPP_NULLPTR diff --git a/contrib/libc++/include/__split_buffer b/contrib/libc++/include/__split_buffer index 727b1b6b5674..79d1aa1d7c4a 100644 --- a/contrib/libc++/include/__split_buffer +++ b/contrib/libc++/include/__split_buffer @@ -56,9 +56,12 @@ public: _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} + _LIBCPP_INLINE_VISIBILITY __split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(__alloc_rr& __a); + _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(const __alloc_rr& __a); __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); ~__split_buffer(); @@ -128,7 +131,9 @@ public: _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) {__destruct_at_begin(__new_begin, is_trivially_destructible());} + _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, false_type); + _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, true_type); _LIBCPP_INLINE_VISIBILITY @@ -266,7 +271,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { @@ -275,7 +280,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { @@ -309,7 +314,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) @@ -317,14 +322,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { diff --git a/contrib/libc++/include/__tree b/contrib/libc++/include/__tree index 574e74baf26b..94565bc3f74c 100644 --- a/contrib/libc++/include/__tree +++ b/contrib/libc++/include/__tree @@ -548,31 +548,15 @@ template class __tree_node_base : public __tree_end_node < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__tree_node_base<_VoidPtr> > -#else - rebind<__tree_node_base<_VoidPtr> >::other -#endif + typename __rebind_pointer<_VoidPtr, __tree_node_base<_VoidPtr> >::type > { __tree_node_base(const __tree_node_base&); __tree_node_base& operator=(const __tree_node_base&); public: - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__tree_node_base> -#else - rebind<__tree_node_base>::other -#endif - pointer; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - const_pointer; + typedef typename __rebind_pointer<_VoidPtr, __tree_node_base>::type pointer; + typedef typename __rebind_pointer<_VoidPtr, const __tree_node_base>::type const_pointer; + typedef __tree_end_node base; pointer __right_; @@ -623,13 +607,7 @@ public: typedef _Tp value_type; typedef _DiffType difference_type; typedef value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -694,13 +672,7 @@ public: typedef _Tp value_type; typedef _DiffType difference_type; typedef const value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -710,13 +682,8 @@ public: private: typedef typename remove_const<__node>::type __non_const_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__non_const_node> -#else - rebind<__non_const_node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type + __non_const_node_pointer; typedef __tree_iterator __non_const_iterator; public: @@ -730,14 +697,8 @@ public: _LIBCPP_INLINE_VISIBILITY __tree_const_iterator& operator++() { - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - __node_base_pointer; - + typedef typename __rebind_pointer<__node_pointer, typename __node::base>::type + __node_base_pointer; __ptr_ = static_cast<__node_pointer>( __tree_next(static_cast<__node_base_pointer>(__ptr_))); return *this; @@ -749,14 +710,8 @@ public: _LIBCPP_INLINE_VISIBILITY __tree_const_iterator& operator--() { - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - __node_base_pointer; - + typedef typename __rebind_pointer<__node_pointer, typename __node::base>::type + __node_base_pointer; __ptr_ = static_cast<__node_pointer>( __tree_prev(static_cast<__node_base_pointer>(__ptr_))); return *this; @@ -810,20 +765,9 @@ public: typedef typename __node_base::pointer __node_base_const_pointer; private: typedef typename __node_base::base __end_node_t; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__end_node_t> -#else - rebind<__end_node_t>::other -#endif - __end_node_ptr; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__end_node_t> -#else - rebind<__end_node_t>::other -#endif - __end_node_const_ptr; + typedef typename __rebind_pointer<__node_pointer, __end_node_t>::type + __end_node_ptr; + typedef __end_node_ptr __end_node_const_ptr; __node_pointer __begin_node_; __compressed_pair<__end_node_t, __node_allocator> __pair1_; @@ -965,6 +909,13 @@ public: iterator __insert_multi(const value_type& __v); iterator __insert_multi(const_iterator __p, const value_type& __v); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + pair __insert_unique( value_type&& __v); + iterator __insert_unique(const_iterator __p, value_type&& __v); + iterator __insert_multi( value_type&& __v); + iterator __insert_multi(const_iterator __p, value_type&& __v); +#endif + pair __node_insert_unique(__node_pointer __nd); iterator __node_insert_unique(const_iterator __p, __node_pointer __nd); @@ -1118,8 +1069,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) template __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) - : __pair1_(__node_allocator(__a)), - __begin_node_(__node_pointer()), + : __begin_node_(__node_pointer()), + __pair1_(__node_allocator(__a)), __pair3_(0) { __begin_node() = __end_node(); @@ -1128,8 +1079,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) template __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) - : __pair1_(__node_allocator(__a)), - __begin_node_(__node_pointer()), + : __begin_node_(__node_pointer()), + __pair1_(__node_allocator(__a)), __pair3_(0, __comp) { __begin_node() = __end_node(); @@ -1785,6 +1736,28 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, #endif // _LIBCPP_HAS_NO_VARIADICS +template +pair::iterator, bool> +__tree<_Tp, _Compare, _Allocator>::__insert_unique(value_type&& __v) +{ + __node_holder __h = __construct_node(_VSTD::forward(__v)); + pair __r = __node_insert_unique(__h.get()); + if (__r.second) + __h.release(); + return __r; +} + +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, value_type&& __v) +{ + __node_holder __h = __construct_node(_VSTD::forward(__v)); + iterator __r = __node_insert_unique(__p, __h.get()); + if (__r.__ptr_ == __h.get()) + __h.release(); + return __r; +} + template template pair::iterator, bool> @@ -1809,6 +1782,28 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, _Vp&& __v return __r; } +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_multi(value_type&& __v) +{ + __node_base_pointer __parent; + __node_base_pointer& __child = __find_leaf_high(__parent, __v); + __node_holder __h = __construct_node(_VSTD::forward(__v)); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); + return iterator(__h.release()); +} + +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, value_type&& __v) +{ + __node_base_pointer __parent; + __node_base_pointer& __child = __find_leaf(__p, __parent, __v); + __node_holder __h = __construct_node(_VSTD::forward(__v)); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); + return iterator(__h.release()); +} + template template typename __tree<_Tp, _Compare, _Allocator>::iterator @@ -1843,7 +1838,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_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 2837ce708f09..8c31759774de 100644 --- a/contrib/libc++/include/__tuple +++ b/contrib/libc++/include/__tuple @@ -86,6 +86,11 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&&) _NOEXCEPT; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, tuple<_Tp...> >::type&& +get(const tuple<_Tp...>&&) _NOEXCEPT; #endif // pair specializations @@ -109,6 +114,11 @@ template _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_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& +get(const pair<_T1, _T2>&&) _NOEXCEPT; #endif // array specializations @@ -132,35 +142,15 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp&& +get(const array<_Tp, _Size>&&) _NOEXCEPT; #endif #if !defined(_LIBCPP_HAS_NO_VARIADICS) -// __lazy_and - -template -struct __lazy_and_impl; - -template -struct __lazy_and_impl : false_type {}; - -template <> -struct __lazy_and_impl : true_type {}; - -template -struct __lazy_and_impl : integral_constant {}; - -template -struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; - -template -struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; - -// __lazy_not - -template -struct __lazy_not : integral_constant {}; - // __make_tuple_indices template struct __tuple_indices {}; diff --git a/contrib/libc++/include/algorithm b/contrib/libc++/include/algorithm index 7b0c53e05a5a..71e5df37dfeb 100644 --- a/contrib/libc++/include/algorithm +++ b/contrib/libc++/include/algorithm @@ -851,7 +851,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _VSTD::move(__f); // explicitly moved for (emulated) C++03 + return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03 } // find @@ -1687,25 +1687,6 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const } // copy - -template -struct __libcpp_is_trivial_iterator -{ - static const bool value = is_pointer<_Iter>::value; -}; - -template -struct __libcpp_is_trivial_iterator > -{ - static const bool value = is_pointer<_Iter>::value; -}; - -template -struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > -{ - static const bool value = is_pointer<_Iter>::value; -}; - template inline _LIBCPP_INLINE_VISIBILITY _Iter @@ -2330,7 +2311,7 @@ __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirec { if (__first == --__last) break; - swap(*__first, *__last); + _VSTD::iter_swap(__first, __last); ++__first; } } @@ -2342,7 +2323,7 @@ __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_ac { if (__first != __last) for (; __first < --__last; ++__first) - swap(*__first, *__last); + _VSTD::iter_swap(__first, __last); } template @@ -3037,7 +3018,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p if (_Rp == 0) return static_cast(_Eng(__g, _Dt)()); size_t __w = _Dt - __clz(_Rp) - 1; - if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0) + if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0) ++__w; _Eng __e(__g, __w); _UIntType __u; diff --git a/contrib/libc++/include/array b/contrib/libc++/include/array index 2e02a43ed524..8866eaf6b463 100644 --- a/contrib/libc++/include/array +++ b/contrib/libc++/include/array @@ -89,12 +89,13 @@ template void swap(array& x, array& y) noexcept(noexcept(x.swap(y))); template class tuple_size; -template class tuple_element; +template class tuple_element; template struct tuple_size>; -template struct tuple_element>; -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 +template struct tuple_element>; +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 +template const T&& get(const array&&) noexcept; // constexpr in C++14 } // std @@ -324,6 +325,15 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT return _VSTD::move(__a.__elems_[_Ip]); } +template +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 _VSTD::move(__a.__elems_[_Ip]); +} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/atomic b/contrib/libc++/include/atomic index 92b9c4dd4642..abec2a0b565a 100644 --- a/contrib/libc++/include/atomic +++ b/contrib/libc++/include/atomic @@ -535,21 +535,20 @@ void atomic_signal_fence(memory_order m) noexcept; #ifdef _LIBCPP_HAS_NO_THREADS #error is not supported on this single threaded system -#else // !_LIBCPP_HAS_NO_THREADS +#endif +#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) +#error is not implemented +#endif _LIBCPP_BEGIN_NAMESPACE_STD -#if !__has_feature(cxx_atomic) && _GNUC_VER < 407 -#error is not implemented -#else - typedef enum memory_order { memory_order_relaxed, memory_order_consume, memory_order_acquire, memory_order_release, memory_order_acq_rel, memory_order_seq_cst } memory_order; -#if _GNUC_VER >= 407 +#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) namespace __gcc_atomic { template struct __gcc_atomic_t { @@ -816,7 +815,7 @@ static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, return __atomic_fetch_xor(&__a->__a_value, __pattern, __gcc_atomic::__to_gcc_order(__order)); } -#endif // _GNUC_VER >= 407 +#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP template inline _LIBCPP_INLINE_VISIBILITY @@ -836,7 +835,7 @@ struct __atomic_base // false _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const volatile _NOEXCEPT { -#if __has_feature(cxx_atomic) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) return __c11_atomic_is_lock_free(sizeof(_Tp)); #else return __atomic_is_lock_free(sizeof(_Tp), 0); @@ -1790,8 +1789,6 @@ typedef atomic atomic_uintmax_t; #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(__v) {__v} -// lock-free property - #define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE #define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE #define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE @@ -1803,10 +1800,6 @@ typedef atomic atomic_uintmax_t; #define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE #define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE -#endif // !__has_feature(cxx_atomic) - _LIBCPP_END_NAMESPACE_STD -#endif // !_LIBCPP_HAS_NO_THREADS - #endif // _LIBCPP_ATOMIC diff --git a/contrib/libc++/include/bitset b/contrib/libc++/include/bitset index 8c278cc724f1..87d7afca5a73 100644 --- a/contrib/libc++/include/bitset +++ b/contrib/libc++/include/bitset @@ -168,7 +168,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT @@ -180,8 +182,11 @@ protected: _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} + _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset& __v) _NOEXCEPT; void flip() _NOEXCEPT; @@ -192,22 +197,27 @@ protected: bool all() const _NOEXCEPT; bool any() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT; private: #ifdef _LIBCPP_HAS_NO_CONSTEXPR void __init(unsigned long long __v, false_type) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void __init(unsigned long long __v, true_type) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_CONSTEXPR unsigned long to_ulong(false_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong(true_type) const; unsigned long long to_ullong(false_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong(true_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong(true_type, false_type) const; unsigned long long to_ullong(true_type, true_type) const; }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR @@ -245,7 +255,7 @@ __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT #endif // _LIBCPP_HAS_NO_CONSTEXPR template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR @@ -264,7 +274,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { @@ -273,7 +283,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { @@ -282,7 +292,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { @@ -325,7 +335,7 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long __bitset<_N_words, _Size>::to_ulong(true_type) const { @@ -348,7 +358,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type) const { @@ -356,7 +366,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const { @@ -414,7 +424,7 @@ __bitset<_N_words, _Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT { @@ -450,7 +460,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT @@ -462,23 +474,32 @@ protected: _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} + _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const; + _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT; }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) @@ -486,7 +507,7 @@ __bitset<1, _Size>::__bitset() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT : __first_(static_cast<__storage_type>(__v)) @@ -494,7 +515,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { @@ -502,7 +523,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { @@ -510,7 +531,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { @@ -518,7 +539,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::flip() _NOEXCEPT { @@ -528,7 +549,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long __bitset<1, _Size>::to_ulong() const { @@ -536,7 +557,7 @@ __bitset<1, _Size>::to_ulong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<1, _Size>::to_ullong() const { @@ -544,7 +565,7 @@ __bitset<1, _Size>::to_ullong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool __bitset<1, _Size>::all() const _NOEXCEPT { @@ -553,7 +574,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool __bitset<1, _Size>::any() const _NOEXCEPT { @@ -562,7 +583,7 @@ __bitset<1, _Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT { @@ -593,7 +614,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT @@ -620,13 +643,13 @@ protected: _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} }; -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT { } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT { @@ -663,16 +686,23 @@ public: _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); // 23.3.5.2 bitset operations: + _LIBCPP_INLINE_VISIBILITY bitset& operator&=(const bitset& __rhs) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& operator|=(const bitset& __rhs) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& operator^=(const bitset& __rhs) _NOEXCEPT; bitset& operator<<=(size_t __pos) _NOEXCEPT; bitset& operator>>=(size_t __pos) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& set() _NOEXCEPT; bitset& set(size_t __pos, bool __val = true); + _LIBCPP_INLINE_VISIBILITY bitset& reset() _NOEXCEPT; bitset& reset(size_t __pos); + _LIBCPP_INLINE_VISIBILITY bitset operator~() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& flip() _NOEXCEPT; bitset& flip(size_t __pos); @@ -680,28 +710,40 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);} _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const; template basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template + _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template + _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; + _LIBCPP_INLINE_VISIBILITY basic_string, allocator > to_string(char __zero = '0', char __one = '1') const; + _LIBCPP_INLINE_VISIBILITY size_t count() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} + _LIBCPP_INLINE_VISIBILITY bool operator==(const bitset& __rhs) const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool operator!=(const bitset& __rhs) const _NOEXCEPT; bool test(size_t __pos) const; + _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();} + _LIBCPP_INLINE_VISIBILITY bitset operator<<(size_t __pos) const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset operator>>(size_t __pos) const _NOEXCEPT; private: @@ -774,7 +816,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT { @@ -783,7 +825,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT { @@ -792,7 +834,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT { @@ -821,7 +863,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::set() _NOEXCEPT { @@ -844,7 +886,7 @@ bitset<_Size>::set(size_t __pos, bool __val) } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT { @@ -867,7 +909,7 @@ bitset<_Size>::reset(size_t __pos) } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator~() const _NOEXCEPT { @@ -877,7 +919,7 @@ bitset<_Size>::operator~() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT { @@ -901,7 +943,7 @@ bitset<_Size>::flip(size_t __pos) } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long bitset<_Size>::to_ulong() const { @@ -909,7 +951,7 @@ bitset<_Size>::to_ulong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long bitset<_Size>::to_ullong() const { @@ -932,7 +974,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, _Traits, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -941,7 +983,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -949,7 +991,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string, allocator > bitset<_Size>::to_string(char __zero, char __one) const { @@ -957,7 +999,7 @@ bitset<_Size>::to_string(char __zero, char __one) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t bitset<_Size>::count() const _NOEXCEPT { @@ -965,7 +1007,7 @@ bitset<_Size>::count() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT { @@ -973,7 +1015,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT { @@ -994,7 +1036,7 @@ bitset<_Size>::test(size_t __pos) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::all() const _NOEXCEPT { @@ -1002,7 +1044,7 @@ bitset<_Size>::all() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::any() const _NOEXCEPT { @@ -1010,7 +1052,7 @@ bitset<_Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT { @@ -1020,7 +1062,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT { diff --git a/contrib/libc++/include/cctype b/contrib/libc++/include/cctype index 26c740f7382d..a68c2a06604d 100644 --- a/contrib/libc++/include/cctype +++ b/contrib/libc++/include/cctype @@ -37,10 +37,6 @@ int toupper(int c); #include <__config> #include -#if defined(_LIBCPP_MSVCRT) -#include "support/win32/support.h" -#include "support/win32/locale_win32.h" -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -48,117 +44,20 @@ int toupper(int c); _LIBCPP_BEGIN_NAMESPACE_STD -#ifdef isalnum -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalnum(int __c) {return isalnum(__c);} -#undef isalnum -inline _LIBCPP_INLINE_VISIBILITY int isalnum(int __c) {return __libcpp_isalnum(__c);} -#else // isalnum using ::isalnum; -#endif // isalnum - -#ifdef isalpha -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalpha(int __c) {return isalpha(__c);} -#undef isalpha -inline _LIBCPP_INLINE_VISIBILITY int isalpha(int __c) {return __libcpp_isalpha(__c);} -#else // isalpha using ::isalpha; -#endif // isalpha - -#ifdef isblank -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isblank(int __c) {return isblank(__c);} -#undef isblank -inline _LIBCPP_INLINE_VISIBILITY int isblank(int __c) {return __libcpp_isblank(__c);} -#else // isblank using ::isblank; -#endif // isblank - -#ifdef iscntrl -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iscntrl(int __c) {return iscntrl(__c);} -#undef iscntrl -inline _LIBCPP_INLINE_VISIBILITY int iscntrl(int __c) {return __libcpp_iscntrl(__c);} -#else // iscntrl using ::iscntrl; -#endif // iscntrl - -#ifdef isdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isdigit(int __c) {return isdigit(__c);} -#undef isdigit -inline _LIBCPP_INLINE_VISIBILITY int isdigit(int __c) {return __libcpp_isdigit(__c);} -#else // isdigit using ::isdigit; -#endif // isdigit - -#ifdef isgraph -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isgraph(int __c) {return isgraph(__c);} -#undef isgraph -inline _LIBCPP_INLINE_VISIBILITY int isgraph(int __c) {return __libcpp_isgraph(__c);} -#else // isgraph using ::isgraph; -#endif // isgraph - -#ifdef islower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_islower(int __c) {return islower(__c);} -#undef islower -inline _LIBCPP_INLINE_VISIBILITY int islower(int __c) {return __libcpp_islower(__c);} -#else // islower using ::islower; -#endif // islower - -#ifdef isprint -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isprint(int __c) {return isprint(__c);} -#undef isprint -inline _LIBCPP_INLINE_VISIBILITY int isprint(int __c) {return __libcpp_isprint(__c);} -#else // isprint using ::isprint; -#endif // isprint - -#ifdef ispunct -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ispunct(int __c) {return ispunct(__c);} -#undef ispunct -inline _LIBCPP_INLINE_VISIBILITY int ispunct(int __c) {return __libcpp_ispunct(__c);} -#else // ispunct using ::ispunct; -#endif // ispunct - -#ifdef isspace -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isspace(int __c) {return isspace(__c);} -#undef isspace -inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_isspace(__c);} -#else // isspace using ::isspace; -#endif // isspace - -#ifdef isupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isupper(int __c) {return isupper(__c);} -#undef isupper -inline _LIBCPP_INLINE_VISIBILITY int isupper(int __c) {return __libcpp_isupper(__c);} -#else // isupper using ::isupper; -#endif // isupper - -#ifdef isxdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);} -#undef isxdigit -inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);} -#else // isxdigit using ::isxdigit; -#endif // isxdigit - -#ifdef tolower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_tolower(int __c) {return tolower(__c);} -#undef tolower -inline _LIBCPP_INLINE_VISIBILITY int tolower(int __c) {return __libcpp_tolower(__c);} -#else // tolower using ::tolower; -#endif // tolower - -#ifdef toupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_toupper(int __c) {return toupper(__c);} -#undef toupper -inline _LIBCPP_INLINE_VISIBILITY int toupper(int __c) {return __libcpp_toupper(__c);} -#else // toupper using ::toupper; -#endif // toupper _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/cerrno b/contrib/libc++/include/cerrno index 9804e4e3dcfe..bab13b8aa861 100644 --- a/contrib/libc++/include/cerrno +++ b/contrib/libc++/include/cerrno @@ -30,364 +30,4 @@ Macros: #pragma GCC system_header #endif -#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) - -#ifdef ELAST - -const int __elast1 = ELAST+1; -const int __elast2 = ELAST+2; - -#else - -const int __elast1 = 104; -const int __elast2 = 105; - -#endif - -#ifdef ENOTRECOVERABLE - -#define EOWNERDEAD __elast1 - -#ifdef ELAST -#undef ELAST -#define ELAST EOWNERDEAD -#endif - -#elif defined(EOWNERDEAD) - -#define ENOTRECOVERABLE __elast1 -#ifdef ELAST -#undef ELAST -#define ELAST ENOTRECOVERABLE -#endif - -#else // defined(EOWNERDEAD) - -#define EOWNERDEAD __elast1 -#define ENOTRECOVERABLE __elast2 -#ifdef ELAST -#undef ELAST -#define ELAST ENOTRECOVERABLE -#endif - -#endif // defined(EOWNERDEAD) - -#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) - -// supply errno values likely to be missing, particularly on Windows - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT 9901 -#endif - -#ifndef EADDRINUSE -#define EADDRINUSE 9902 -#endif - -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL 9903 -#endif - -#ifndef EISCONN -#define EISCONN 9904 -#endif - -#ifndef EBADMSG -#define EBADMSG 9905 -#endif - -#ifndef ECONNABORTED -#define ECONNABORTED 9906 -#endif - -#ifndef EALREADY -#define EALREADY 9907 -#endif - -#ifndef ECONNREFUSED -#define ECONNREFUSED 9908 -#endif - -#ifndef ECONNRESET -#define ECONNRESET 9909 -#endif - -#ifndef EDESTADDRREQ -#define EDESTADDRREQ 9910 -#endif - -#ifndef EHOSTUNREACH -#define EHOSTUNREACH 9911 -#endif - -#ifndef EIDRM -#define EIDRM 9912 -#endif - -#ifndef EMSGSIZE -#define EMSGSIZE 9913 -#endif - -#ifndef ENETDOWN -#define ENETDOWN 9914 -#endif - -#ifndef ENETRESET -#define ENETRESET 9915 -#endif - -#ifndef ENETUNREACH -#define ENETUNREACH 9916 -#endif - -#ifndef ENOBUFS -#define ENOBUFS 9917 -#endif - -#ifndef ENOLINK -#define ENOLINK 9918 -#endif - -#ifndef ENODATA -#define ENODATA 9919 -#endif - -#ifndef ENOMSG -#define ENOMSG 9920 -#endif - -#ifndef ENOPROTOOPT -#define ENOPROTOOPT 9921 -#endif - -#ifndef ENOSR -#define ENOSR 9922 -#endif - -#ifndef ENOTSOCK -#define ENOTSOCK 9923 -#endif - -#ifndef ENOSTR -#define ENOSTR 9924 -#endif - -#ifndef ENOTCONN -#define ENOTCONN 9925 -#endif - -#ifndef ENOTSUP -#define ENOTSUP 9926 -#endif - -#ifndef ECANCELED -#define ECANCELED 9927 -#endif - -#ifndef EINPROGRESS -#define EINPROGRESS 9928 -#endif - -#ifndef EOPNOTSUPP -#define EOPNOTSUPP 9929 -#endif - -#ifndef EWOULDBLOCK -#define EWOULDBLOCK 9930 -#endif - -#ifndef EOWNERDEAD -#define EOWNERDEAD 9931 -#endif - -#ifndef EPROTO -#define EPROTO 9932 -#endif - -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT 9933 -#endif - -#ifndef ENOTRECOVERABLE -#define ENOTRECOVERABLE 9934 -#endif - -#ifndef ETIME -#define ETIME 9935 -#endif - -#ifndef ETXTBSY -#define ETXTBSY 9936 -#endif - -#ifndef ETIMEDOUT -#define ETIMEDOUT 9938 -#endif - -#ifndef ELOOP -#define ELOOP 9939 -#endif - -#ifndef EOVERFLOW -#define EOVERFLOW 9940 -#endif - -#ifndef EPROTOTYPE -#define EPROTOTYPE 9941 -#endif - -#ifndef ENOSYS -#define ENOSYS 9942 -#endif - -#ifndef EINVAL -#define EINVAL 9943 -#endif - -#ifndef ERANGE -#define ERANGE 9944 -#endif - -#ifndef EILSEQ -#define EILSEQ 9945 -#endif - -// Windows Mobile doesn't appear to define these: - -#ifndef E2BIG -#define E2BIG 9946 -#endif - -#ifndef EDOM -#define EDOM 9947 -#endif - -#ifndef EFAULT -#define EFAULT 9948 -#endif - -#ifndef EBADF -#define EBADF 9949 -#endif - -#ifndef EPIPE -#define EPIPE 9950 -#endif - -#ifndef EXDEV -#define EXDEV 9951 -#endif - -#ifndef EBUSY -#define EBUSY 9952 -#endif - -#ifndef ENOTEMPTY -#define ENOTEMPTY 9953 -#endif - -#ifndef ENOEXEC -#define ENOEXEC 9954 -#endif - -#ifndef EEXIST -#define EEXIST 9955 -#endif - -#ifndef EFBIG -#define EFBIG 9956 -#endif - -#ifndef ENAMETOOLONG -#define ENAMETOOLONG 9957 -#endif - -#ifndef ENOTTY -#define ENOTTY 9958 -#endif - -#ifndef EINTR -#define EINTR 9959 -#endif - -#ifndef ESPIPE -#define ESPIPE 9960 -#endif - -#ifndef EIO -#define EIO 9961 -#endif - -#ifndef EISDIR -#define EISDIR 9962 -#endif - -#ifndef ECHILD -#define ECHILD 9963 -#endif - -#ifndef ENOLCK -#define ENOLCK 9964 -#endif - -#ifndef ENOSPC -#define ENOSPC 9965 -#endif - -#ifndef ENXIO -#define ENXIO 9966 -#endif - -#ifndef ENODEV -#define ENODEV 9967 -#endif - -#ifndef ENOENT -#define ENOENT 9968 -#endif - -#ifndef ESRCH -#define ESRCH 9969 -#endif - -#ifndef ENOTDIR -#define ENOTDIR 9970 -#endif - -#ifndef ENOMEM -#define ENOMEM 9971 -#endif - -#ifndef EPERM -#define EPERM 9972 -#endif - -#ifndef EACCES -#define EACCES 9973 -#endif - -#ifndef EROFS -#define EROFS 9974 -#endif - -#ifndef EDEADLK -#define EDEADLK 9975 -#endif - -#ifndef EAGAIN -#define EAGAIN 9976 -#endif - -#ifndef ENFILE -#define ENFILE 9977 -#endif - -#ifndef EMFILE -#define EMFILE 9978 -#endif - -#ifndef EMLINK -#define EMLINK 9979 -#endif - #endif // _LIBCPP_CERRNO diff --git a/contrib/libc++/include/cfenv b/contrib/libc++/include/cfenv index dd7db37f8e48..4fc630419bde 100644 --- a/contrib/libc++/include/cfenv +++ b/contrib/libc++/include/cfenv @@ -1,5 +1,5 @@ // -*- C++ -*- -//===---------------------------- cctype ----------------------------------===// +//===---------------------------- cfenv -----------------------------------===// // // The LLVM Compiler Infrastructure // diff --git a/contrib/libc++/include/cfloat b/contrib/libc++/include/cfloat index 5fa56550fa6a..176fa9de3cec 100644 --- a/contrib/libc++/include/cfloat +++ b/contrib/libc++/include/cfloat @@ -67,12 +67,4 @@ Macros: #pragma GCC system_header #endif -#ifndef FLT_EVAL_METHOD -#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ -#endif - -#ifndef DECIMAL_DIG -#define DECIMAL_DIG __DECIMAL_DIG__ -#endif - #endif // _LIBCPP_CFLOAT diff --git a/contrib/libc++/include/chrono b/contrib/libc++/include/chrono index 9229234ce55a..68484e982432 100644 --- a/contrib/libc++/include/chrono +++ b/contrib/libc++/include/chrono @@ -26,6 +26,9 @@ duration_cast(const duration& fd); template struct treat_as_floating_point : is_floating_point {}; +template constexpr bool treat_as_floating_point_v + = treat_as_floating_point::value; // C++17 + template struct duration_values { @@ -194,6 +197,13 @@ template template ToDuration duration_cast(const duration& d); +template + constexpr ToDuration floor(const duration& d); // C++17 +template + constexpr ToDuration ceil(const duration& d); // C++17 +template + constexpr ToDuration round(const duration& d); // C++17 + // time_point arithmetic (all constexpr in C++14) template time_point>::type> @@ -227,6 +237,20 @@ template template time_point time_point_cast(const time_point& t); +template + constexpr time_point + floor(const time_point& tp); // C++17 + +template + constexpr time_point + ceil(const time_point& tp); // C++17 + +template + constexpr time_point + round(const time_point& tp); // C++17 + +template + constexpr duration abs(duration d); // C++17 // Clocks class system_clock @@ -392,6 +416,11 @@ duration_cast(const duration<_Rep, _Period>& __fd) template struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool treat_as_floating_point_v + = treat_as_floating_point<_Rep>::value; +#endif + template struct _LIBCPP_TYPE_VIS_ONLY duration_values { @@ -401,6 +430,58 @@ public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() {return numeric_limits<_Rep>::lowest();} }; +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +floor(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t > __d) + __t = __t - _ToDuration{1}; + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +ceil(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t < __d) + __t = __t + _ToDuration{1}; + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +round(const duration<_Rep, _Period>& __d) +{ + _ToDuration __lower = floor<_ToDuration>(__d); + _ToDuration __upper = __lower + _ToDuration{1}; + auto __lowerDiff = __d - __lower; + auto __upperDiff = __upper - __d; + if (__lowerDiff < __upperDiff) + return __lower; + if (__lowerDiff > __upperDiff) + return __upper; + return __lower.count() & 1 ? __upper : __lower; +} +#endif + // duration template @@ -807,6 +888,56 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); } +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +floor(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +ceil(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +round(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + numeric_limits<_Rep>::is_signed, + duration<_Rep, _Period> +>::type +abs(duration<_Rep, _Period> __d) +{ + return __d >= __d.zero() ? __d : -__d; +} +#endif + // time_point == template diff --git a/contrib/libc++/include/cinttypes b/contrib/libc++/include/cinttypes index cfd763c98f4a..3f61b0634b17 100644 --- a/contrib/libc++/include/cinttypes +++ b/contrib/libc++/include/cinttypes @@ -246,10 +246,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int _LIBCPP_BEGIN_NAMESPACE_STD using::imaxdiv_t; - -#undef imaxabs using::imaxabs; -#undef imaxdiv using::imaxdiv; using::strtoimax; using::strtoumax; diff --git a/contrib/libc++/include/cmath b/contrib/libc++/include/cmath index 5f9aaedd5afa..ebbde18168ff 100644 --- a/contrib/libc++/include/cmath +++ b/contrib/libc++/include/cmath @@ -299,340 +299,11 @@ long double truncl(long double x); #include <__config> #include -#include - -#ifdef _LIBCPP_MSVCRT -#include "support/win32/math_win32.h" -#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -// signbit - -#ifdef signbit - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return signbit(__lcpp_x); -} - -#undef signbit - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // signbit - -// fpclassify - -#ifdef fpclassify - -template -_LIBCPP_ALWAYS_INLINE -int -__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return fpclassify(__lcpp_x); -} - -#undef fpclassify - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // fpclassify - -// isfinite - -#ifdef isfinite - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT -{ - return isfinite(__lcpp_x); -} - -#undef isfinite - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isfinite(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isfinite - -// isinf - -#ifdef isinf - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT -{ - return isinf(__lcpp_x); -} - -#undef isinf - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isinf(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isinf - -// isnan - -#ifdef isnan - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT -{ - return isnan(__lcpp_x); -} - -#undef isnan - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnan(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isnan - -// isnormal - -#ifdef isnormal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT -{ - return isnormal(__lcpp_x); -} - -#undef isnormal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnormal(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isnormal - -// isgreater - -#ifdef isgreater - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreater(__lcpp_x, __lcpp_y); -} - -#undef isgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreater - -// isgreaterequal - -#ifdef isgreaterequal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreaterequal(__lcpp_x, __lcpp_y); -} - -#undef isgreaterequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreaterequal - -// isless - -#ifdef isless - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isless(__lcpp_x, __lcpp_y); -} - -#undef isless - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isless - -// islessequal - -#ifdef islessequal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessequal(__lcpp_x, __lcpp_y); -} - -#undef islessequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // islessequal - -// islessgreater - -#ifdef islessgreater - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessgreater(__lcpp_x, __lcpp_y); -} - -#undef islessgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // islessgreater - -// isunordered - -#ifdef isunordered - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isunordered(__lcpp_x, __lcpp_y); -} - -#undef isunordered - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isunordered - _LIBCPP_BEGIN_NAMESPACE_STD using ::signbit; @@ -652,794 +323,130 @@ using ::isunordered; using ::float_t; using ::double_t; -// abs - -#if defined(__sun__) +#ifndef _AIX using ::abs; #endif -#if !defined(_AIX) && !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY -float -abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} - -inline _LIBCPP_INLINE_VISIBILITY -double -abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);} - -inline _LIBCPP_INLINE_VISIBILITY -long double -abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} -#endif // !defined(_AIX) - #ifndef __sun__ - -// acos - using ::acos; using ::acosf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);} - -// asin - using ::asin; using ::asinf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);} - -// atan - using ::atan; using ::atanf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);} - -// atan2 - using ::atan2; using ::atan2f; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); -} - -// ceil - using ::ceil; using ::ceilf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);} - -// cos - using ::cos; using ::cosf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);} - -// cosh - using ::cosh; using ::coshf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);} - #endif // __sun__ -// exp using ::exp; using ::expf; #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} -#endif - - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);} - -// fabs - using ::fabs; using ::fabsf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);} - -// floor - using ::floor; using ::floorf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);} - -// fmod - #endif //__sun__ + using ::fmod; using ::fmodf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - - -// frexp - using ::frexp; using ::frexpf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);} - -// ldexp - using ::ldexp; using ::ldexpf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);} - -// log - #endif // __sun__ + using ::log; using ::logf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);} - - -// log10 - using ::log10; using ::log10f; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);} - -// modf - using ::modf; using ::modff; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} -#endif - -// pow - #endif // __sun__ + using ::pow; using ::powf; #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// sin - using ::sin; using ::sinf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);} - -// sinh - using ::sinh; using ::sinhf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);} - -// sqrt - #endif // __sun__ + using ::sqrt; using ::sqrtf; - - -#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} - -// tan - using ::tan; using ::tanf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);} - -// tanh - using ::tanh; using ::tanhf; -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);} - -// acosh - #ifndef _LIBCPP_MSVCRT using ::acosh; using ::acoshf; - -inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);} -#endif - -// asinh - -#ifndef _LIBCPP_MSVCRT using ::asinh; using ::asinhf; - -inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);} -#endif - -// atanh - -#ifndef _LIBCPP_MSVCRT using ::atanh; using ::atanhf; - -inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);} -#endif - -// cbrt - -#ifndef _LIBCPP_MSVCRT using ::cbrt; using ::cbrtf; - -inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} #endif -// copysign - using ::copysign; using ::copysignf; -#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12) -inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, - float __lcpp_y) _NOEXCEPT { - return copysignf(__lcpp_x, __lcpp_y); -} -inline _LIBCPP_INLINE_VISIBILITY long double -copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { - return copysignl(__lcpp_x, __lcpp_y); -} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - #ifndef _LIBCPP_MSVCRT - -// erf - using ::erf; using ::erff; - -inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);} - -// erfc - using ::erfc; using ::erfcf; - -inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);} - -// exp2 - using ::exp2; using ::exp2f; - -inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);} - -// expm1 - using ::expm1; using ::expm1f; - -inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);} - -// fdim - using ::fdim; using ::fdimf; - -inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fma - using ::fmaf; using ::fma; - -inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);} -inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value && - is_arithmetic<_A3>::value, - __promote<_A1, _A2, _A3> ->::type -fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2, _A3>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value && - is_same<_A3, __result_type>::value)), ""); - return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); -} - -// fmax - using ::fmax; using ::fmaxf; - -inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fmin - using ::fmin; using ::fminf; - -inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// hypot - using ::hypot; using ::hypotf; - -inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// ilogb - using ::ilogb; using ::ilogbf; - -inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, int>::type -ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);} - -// lgamma - using ::lgamma; using ::lgammaf; - -inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);} - - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);} - - -// llrint - using ::llrint; using ::llrintf; - -inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long long>::type -llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);} - -// llround - using ::llround; using ::llroundf; - -inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long long>::type -llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);} - -// log1p - using ::log1p; using ::log1pf; - -inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);} - -// log2 - using ::log2; using ::log2f; - -inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);} - -// logb - using ::logb; using ::logbf; - -inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);} - -// lrint - using ::lrint; using ::lrintf; - -inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long>::type -lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);} - -// lround - using ::lround; using ::lroundf; - -inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long>::type -lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);} - #endif // _LIBCPP_MSVCRT #endif // __sun__ -// nan - #ifndef _LIBCPP_MSVCRT using ::nan; using ::nanf; @@ -1447,183 +454,28 @@ using ::nanf; #ifndef __sun__ #ifndef _LIBCPP_MSVCRT - -// nearbyint - using ::nearbyint; using ::nearbyintf; - -inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);} - -// nextafter - using ::nextafter; using ::nextafterf; - -inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// nexttoward - using ::nexttoward; using ::nexttowardf; - -inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);} - -// remainder - using ::remainder; using ::remainderf; - -inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// remquo - using ::remquo; using ::remquof; - -inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);} -inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); -} - -// rint - using ::rint; using ::rintf; - -inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);} - -// round - using ::round; using ::roundf; - -inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);} - -// scalbln - using ::scalbln; using ::scalblnf; - -inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);} - -// scalbn - using ::scalbn; using ::scalbnf; - -inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);} - -// tgamma - using ::tgamma; using ::tgammaf; - -inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);} - -// trunc - using ::trunc; using ::truncf; - -inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} - #endif // !_LIBCPP_MSVCRT using ::acosl; @@ -1647,6 +499,7 @@ using ::sinl; using ::sinhl; using ::sqrtl; using ::tanl; + #ifndef _LIBCPP_MSVCRT using ::tanhl; using ::acoshl; @@ -1654,7 +507,9 @@ using ::asinhl; using ::atanhl; using ::cbrtl; #endif // !_LIBCPP_MSVCRT + using ::copysignl; + #ifndef _LIBCPP_MSVCRT using ::erfl; using ::erfcl; @@ -1692,6 +547,7 @@ using ::truncl; using ::lgamma; using ::lgammaf; #endif // __sun__ + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CMATH diff --git a/contrib/libc++/include/complex.h b/contrib/libc++/include/complex.h index 7003d31a89cd..c2359665add5 100644 --- a/contrib/libc++/include/complex.h +++ b/contrib/libc++/include/complex.h @@ -18,6 +18,12 @@ */ +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #ifdef __cplusplus #include @@ -28,8 +34,4 @@ #endif // __cplusplus -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #endif // _LIBCPP_COMPLEX_H diff --git a/contrib/libc++/include/condition_variable b/contrib/libc++/include/condition_variable index 1af2484abd7b..10e007701672 100644 --- a/contrib/libc++/include/condition_variable +++ b/contrib/libc++/include/condition_variable @@ -124,14 +124,18 @@ class _LIBCPP_TYPE_VIS condition_variable_any condition_variable __cv_; shared_ptr __mut_; public: + _LIBCPP_INLINE_VISIBILITY condition_variable_any(); + _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT; template void wait(_Lock& __lock); template + _LIBCPP_INLINE_VISIBILITY void wait(_Lock& __lock, _Predicate __pred); template @@ -141,27 +145,30 @@ public: template bool + _LIBCPP_INLINE_VISIBILITY wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); template cv_status + _LIBCPP_INLINE_VISIBILITY wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d); template bool + _LIBCPP_INLINE_VISIBILITY wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); }; -inline _LIBCPP_INLINE_VISIBILITY +inline condition_variable_any::condition_variable_any() : __mut_(make_shared()) {} -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::notify_one() _NOEXCEPT { @@ -169,7 +176,7 @@ condition_variable_any::notify_one() _NOEXCEPT __cv_.notify_one(); } -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::notify_all() _NOEXCEPT { @@ -196,7 +203,7 @@ condition_variable_any::wait(_Lock& __lock) } // __mut_.unlock(), __lock.lock() template -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) { @@ -218,7 +225,7 @@ condition_variable_any::wait_until(_Lock& __lock, } // __mut_.unlock(), __lock.lock() template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, @@ -231,7 +238,7 @@ condition_variable_any::wait_until(_Lock& __lock, } template -inline _LIBCPP_INLINE_VISIBILITY +inline cv_status condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d) @@ -240,7 +247,7 @@ condition_variable_any::wait_for(_Lock& __lock, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, diff --git a/contrib/libc++/include/csetjmp b/contrib/libc++/include/csetjmp index d0b2c078967d..58a9c73ab56f 100644 --- a/contrib/libc++/include/csetjmp +++ b/contrib/libc++/include/csetjmp @@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val); #pragma GCC system_header #endif -#ifndef setjmp -#define setjmp(env) setjmp(env) -#endif - _LIBCPP_BEGIN_NAMESPACE_STD using ::jmp_buf; diff --git a/contrib/libc++/include/cstddef b/contrib/libc++/include/cstddef index c3ca64a9c014..edd106c001bc 100644 --- a/contrib/libc++/include/cstddef +++ b/contrib/libc++/include/cstddef @@ -35,12 +35,14 @@ Types: #include <__config> -#include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +// Don't include our own ; we don't want to declare ::nullptr_t. +#include_next +#include <__nullptr> + _LIBCPP_BEGIN_NAMESPACE_STD using ::ptrdiff_t; @@ -53,50 +55,6 @@ using ::max_align_t; typedef long double max_align_t; #endif -#ifdef _LIBCPP_HAS_NO_NULLPTR - -struct _LIBCPP_TYPE_VIS_ONLY nullptr_t -{ - void* __lx; - - struct __nat {int __for_bool_;}; - - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} - - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} - - template - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR - operator _Tp* () const {return 0;} - - template - _LIBCPP_ALWAYS_INLINE - operator _Tp _Up::* () const {return 0;} - - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} -}; - -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} - -#define nullptr _VSTD::__get_nullptr_t() - -#endif // _LIBCPP_HAS_NO_NULLPTR - _LIBCPP_END_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_NULLPTR - -namespace std -{ - typedef decltype(nullptr) nullptr_t; -} - -#endif // _LIBCPP_HAS_NO_NULLPTR - #endif // _LIBCPP_CSTDDEF diff --git a/contrib/libc++/include/cstdio b/contrib/libc++/include/cstdio index d8ba6c2ef383..50fdd3457426 100644 --- a/contrib/libc++/include/cstdio +++ b/contrib/libc++/include/cstdio @@ -103,41 +103,6 @@ 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 -inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);} -#endif // getc - -#ifdef putc -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);} -#undef putc -inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);} -#endif // putc - -#ifdef clearerr -inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); } -#undef clearerr -inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); } -#endif // clearerr - -#ifdef feof -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); } -#undef feof -inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); } -#endif // feof - -#ifdef ferror -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); } -#undef ferror -inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); } -#endif // ferror - _LIBCPP_BEGIN_NAMESPACE_STD using ::FILE; diff --git a/contrib/libc++/include/cstdlib b/contrib/libc++/include/cstdlib index 55e15c82192e..10ed231078d8 100644 --- a/contrib/libc++/include/cstdlib +++ b/contrib/libc++/include/cstdlib @@ -84,9 +84,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 #include <__config> #include -#ifdef _LIBCPP_MSVCRT -#include "support/win32/locale_win32.h" -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -131,20 +128,14 @@ using ::getenv; using ::system; using ::bsearch; using ::qsort; -#undef abs using ::abs; -#undef labs using ::labs; #ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef llabs using ::llabs; #endif // _LIBCPP_HAS_NO_LONG_LONG -#undef div using ::div; -#undef ldiv using ::ldiv; #ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef lldiv using ::lldiv; #endif // _LIBCPP_HAS_NO_LONG_LONG #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS @@ -162,19 +153,6 @@ using ::quick_exit; using ::aligned_alloc; #endif -// 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);} -#endif // _LIBCPP_HAS_NO_LONG_LONG - -inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);} -#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 // _LIBCPP_MSVCRT - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTDLIB diff --git a/contrib/libc++/include/ctype.h b/contrib/libc++/include/ctype.h new file mode 100644 index 000000000000..22d6c49be9e1 --- /dev/null +++ b/contrib/libc++/include/ctype.h @@ -0,0 +1,69 @@ +// -*- C++ -*- +//===---------------------------- ctype.h ---------------------------------===// +// +// 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_CTYPE_H +#define _LIBCPP_CTYPE_H + +/* + ctype.h synopsis + +int isalnum(int c); +int isalpha(int c); +int isblank(int c); // C99 +int iscntrl(int c); +int isdigit(int c); +int isgraph(int c); +int islower(int c); +int isprint(int c); +int ispunct(int c); +int isspace(int c); +int isupper(int c); +int isxdigit(int c); +int tolower(int c); +int toupper(int c); +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#if defined(_LIBCPP_MSVCRT) +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { + #include "support/win32/support.h" + #include "support/win32/locale_win32.h" +} +#endif // _LIBCPP_MSVCRT + +#undef isalnum +#undef isalpha +#undef isblank +#undef iscntrl +#undef isdigit +#undef isgraph +#undef islower +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isxdigit +#undef tolower +#undef toupper + +#endif + +#endif // _LIBCPP_CTYPE_H diff --git a/contrib/libc++/include/cwchar b/contrib/libc++/include/cwchar index 797a1777c22f..ef4806db2bde 100644 --- a/contrib/libc++/include/cwchar +++ b/contrib/libc++/include/cwchar @@ -106,9 +106,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, #include <__config> #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include // pull in *swprintf defines -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -161,16 +158,13 @@ using ::wcscoll; using ::wcsncmp; using ::wcsxfrm; -#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) - +#ifdef _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS using ::wcschr; using ::wcspbrk; using ::wcsrchr; using ::wcsstr; using ::wmemchr; - #else - inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} @@ -185,7 +179,6 @@ inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, cons inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} - #endif using ::wcscspn; diff --git a/contrib/libc++/include/cwctype b/contrib/libc++/include/cwctype index 4f89b52db27c..25b2489edf2c 100644 --- a/contrib/libc++/include/cwctype +++ b/contrib/libc++/include/cwctype @@ -63,150 +63,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::wint_t; using ::wctrans_t; using ::wctype_t; - -#ifdef iswalnum -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalnum(wint_t __wc) {return iswalnum(__wc);} -#undef iswalnum -inline _LIBCPP_INLINE_VISIBILITY int iswalnum(wint_t __wc) {return __libcpp_iswalnum(__wc);} -#else // iswalnum using ::iswalnum; -#endif - -#ifdef iswalpha -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalpha(wint_t __wc) {return iswalpha(__wc);} -#undef iswalpha -inline _LIBCPP_INLINE_VISIBILITY int iswalpha(wint_t __wc) {return __libcpp_iswalpha(__wc);} -#else // iswalpha using ::iswalpha; -#endif - -#ifdef iswblank -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswblank(wint_t __wc) {return iswblank(__wc);} -#undef iswblank -inline _LIBCPP_INLINE_VISIBILITY int iswblank(wint_t __wc) {return __libcpp_iswblank(__wc);} -#else // iswblank using ::iswblank; -#endif - -#ifdef iswcntrl -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswcntrl(wint_t __wc) {return iswcntrl(__wc);} -#undef iswcntrl -inline _LIBCPP_INLINE_VISIBILITY int iswcntrl(wint_t __wc) {return __libcpp_iswcntrl(__wc);} -#else // iswcntrl using ::iswcntrl; -#endif - -#ifdef iswdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswdigit(wint_t __wc) {return iswdigit(__wc);} -#undef iswdigit -inline _LIBCPP_INLINE_VISIBILITY int iswdigit(wint_t __wc) {return __libcpp_iswdigit(__wc);} -#else // iswdigit using ::iswdigit; -#endif - -#ifdef iswgraph -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswgraph(wint_t __wc) {return iswgraph(__wc);} -#undef iswgraph -inline _LIBCPP_INLINE_VISIBILITY int iswgraph(wint_t __wc) {return __libcpp_iswgraph(__wc);} -#else // iswgraph using ::iswgraph; -#endif - -#ifdef iswlower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswlower(wint_t __wc) {return iswlower(__wc);} -#undef iswlower -inline _LIBCPP_INLINE_VISIBILITY int iswlower(wint_t __wc) {return __libcpp_iswlower(__wc);} -#else // iswlower using ::iswlower; -#endif - -#ifdef iswprint -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswprint(wint_t __wc) {return iswprint(__wc);} -#undef iswprint -inline _LIBCPP_INLINE_VISIBILITY int iswprint(wint_t __wc) {return __libcpp_iswprint(__wc);} -#else // iswprint using ::iswprint; -#endif - -#ifdef iswpunct -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswpunct(wint_t __wc) {return iswpunct(__wc);} -#undef iswpunct -inline _LIBCPP_INLINE_VISIBILITY int iswpunct(wint_t __wc) {return __libcpp_iswpunct(__wc);} -#else // iswpunct using ::iswpunct; -#endif - -#ifdef iswspace -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswspace(wint_t __wc) {return iswspace(__wc);} -#undef iswspace -inline _LIBCPP_INLINE_VISIBILITY int iswspace(wint_t __wc) {return __libcpp_iswspace(__wc);} -#else // iswspace using ::iswspace; -#endif - -#ifdef iswupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswupper(wint_t __wc) {return iswupper(__wc);} -#undef iswupper -inline _LIBCPP_INLINE_VISIBILITY int iswupper(wint_t __wc) {return __libcpp_iswupper(__wc);} -#else // iswupper using ::iswupper; -#endif - -#ifdef iswxdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswxdigit(wint_t __wc) {return iswxdigit(__wc);} -#undef iswxdigit -inline _LIBCPP_INLINE_VISIBILITY int iswxdigit(wint_t __wc) {return __libcpp_iswxdigit(__wc);} -#else // iswxdigit using ::iswxdigit; -#endif - -#ifdef iswctype -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswctype(wint_t __w, wctype_t __d) {return iswctype(__w, __d);} -#undef iswctype -inline _LIBCPP_INLINE_VISIBILITY int iswctype(wint_t __w, wctype_t __d) {return __libcpp_iswctype(__w, __d);} -#else // iswctype using ::iswctype; -#endif - -#ifdef wctype -inline _LIBCPP_INLINE_VISIBILITY wctype_t __libcpp_wctype(const char* __p) {return wctype(__p);} -#undef wctype -inline _LIBCPP_INLINE_VISIBILITY wctype_t wctype(const char* __p) {return __libcpp_wctype(__p);} -#else // wctype using ::wctype; -#endif - -#ifdef towlower -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towlower(wint_t __wc) {return towlower(__wc);} -#undef towlower -inline _LIBCPP_INLINE_VISIBILITY wint_t towlower(wint_t __wc) {return __libcpp_towlower(__wc);} -#else // towlower using ::towlower; -#endif - -#ifdef towupper -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towupper(wint_t __wc) {return towupper(__wc);} -#undef towupper -inline _LIBCPP_INLINE_VISIBILITY wint_t towupper(wint_t __wc) {return __libcpp_towupper(__wc);} -#else // towupper using ::towupper; -#endif - -#ifdef towctrans -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towctrans(wint_t __wc, wctype_t __d) {return towctrans(__wc, __d);} -#undef towctrans -inline _LIBCPP_INLINE_VISIBILITY wint_t towctrans(wint_t __wc, wctype_t __d) {return __libcpp_towctrans(__wc, __d);} -#else // towctrans using ::towctrans; -#endif - -#ifdef wctrans -inline _LIBCPP_INLINE_VISIBILITY wctrans_t __libcpp_wctrans(const char* __p) {return wctrans(__p);} -#undef wctrans -inline _LIBCPP_INLINE_VISIBILITY wctrans_t wctrans(const char* __p) {return __libcpp_wctrans(__p);} -#else // wctrans using ::wctrans; -#endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/deque b/contrib/libc++/include/deque index 5e152e425d0b..c6fbd512a1c6 100644 --- a/contrib/libc++/include/deque +++ b/contrib/libc++/include/deque @@ -261,8 +261,21 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +template +struct __deque_block_size { + static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; +}; + template + class _DiffType, _DiffType _BS = +#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +// Keep template parameter to avoid changing all template declarations thoughout +// this file. + 0 +#else + __deque_block_size<_ValueType, _DiffType>::value +#endif + > class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; @@ -273,7 +286,7 @@ private: __map_iterator __m_iter_; pointer __ptr_; - static const difference_type __block_size = _BlockSize; + static const difference_type __block_size; public: typedef _ValueType value_type; typedef random_access_iterator_tag iterator_category; @@ -287,7 +300,7 @@ public: template _LIBCPP_INLINE_VISIBILITY - __deque_iterator(const __deque_iterator& __it, + __deque_iterator(const __deque_iterator& __it, typename enable_if::value>::type* = 0) _NOEXCEPT : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {} @@ -520,6 +533,12 @@ private: __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); }; +template +const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, + _DiffType, _BlockSize>::__block_size = + __deque_block_size<_ValueType, _DiffType>::value; + // copy template ::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size; while (__f != __l) { pointer __rb = __r.__ptr_; - pointer __re = *__r.__m_iter_ + _B2; + pointer __re = *__r.__m_iter_ + __block_size; difference_type __bs = __re - __rb; difference_type __n = __l - __f; _RAIter __m = __l; @@ -560,11 +580,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -587,11 +608,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -705,10 +727,11 @@ move(_RAIter __f, { typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size; while (__f != __l) { pointer __rb = __r.__ptr_; - pointer __re = *__r.__m_iter_ + _B2; + pointer __re = *__r.__m_iter_ + __block_size; difference_type __bs = __re - __rb; difference_type __n = __l - __f; _RAIter __m = __l; @@ -733,11 +756,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -760,11 +784,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -909,7 +934,7 @@ protected: typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; - static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16; + static const difference_type __block_size; typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator; typedef allocator_traits<__pointer_allocator> __map_traits; @@ -919,9 +944,9 @@ protected: typedef __split_buffer __map; typedef __deque_iterator iterator; + difference_type> iterator; typedef __deque_iterator const_iterator; + difference_type> const_iterator; __map __map_; size_type __start_; @@ -939,8 +964,10 @@ protected: _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();} + _LIBCPP_INLINE_VISIBILITY __deque_base() _NOEXCEPT_(is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY explicit __deque_base(const allocator_type& __a); public: ~__deque_base(); @@ -996,6 +1023,11 @@ private: {} }; +template +const typename __deque_base<_Tp, _Allocator>::difference_type + __deque_base<_Tp, _Allocator>::__block_size = + __deque_block_size::value; + template bool __deque_base<_Tp, _Allocator>::__invariants() const @@ -1060,13 +1092,13 @@ __deque_base<_Tp, _Allocator>::end() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline __deque_base<_Tp, _Allocator>::__deque_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __start_(0), __size_(0) {} template -inline _LIBCPP_INLINE_VISIBILITY +inline __deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a) : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {} @@ -1164,6 +1196,9 @@ public: typedef _Tp value_type; typedef _Allocator allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef __deque_base __base; typedef typename __base::__alloc_traits __alloc_traits; @@ -1211,8 +1246,11 @@ public: #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value); + _LIBCPP_INLINE_VISIBILITY deque(deque&& __c, const allocator_type& __a); + _LIBCPP_INLINE_VISIBILITY deque& operator=(deque&& __c) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); @@ -1231,6 +1269,7 @@ public: void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT; // iterators: @@ -1283,13 +1322,21 @@ public: bool empty() const _NOEXCEPT {return __base::size() == 0;} // element access: + _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __i); + _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __i) const; + _LIBCPP_INLINE_VISIBILITY reference at(size_type __i); + _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __i) const; + _LIBCPP_INLINE_VISIBILITY reference front(); + _LIBCPP_INLINE_VISIBILITY const_reference front() const; + _LIBCPP_INLINE_VISIBILITY reference back(); + _LIBCPP_INLINE_VISIBILITY const_reference back() const; // 23.2.2.3 modifiers: @@ -1328,6 +1375,7 @@ public: iterator erase(const_iterator __p); iterator erase(const_iterator __f, const_iterator __l); + _LIBCPP_INLINE_VISIBILITY void swap(deque& __c) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; @@ -1335,6 +1383,7 @@ public: _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); #endif + _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -1507,7 +1556,7 @@ deque<_Tp, _Allocator>::operator=(const deque& __c) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>::deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __base(_VSTD::move(__c)) @@ -1515,7 +1564,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a) : __base(_VSTD::move(__c), __a) { @@ -1527,7 +1576,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a) } template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -1611,7 +1660,7 @@ deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Allocator deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT { @@ -1670,7 +1719,7 @@ deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator[](size_type __i) { @@ -1679,7 +1728,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::operator[](size_type __i) const { @@ -1688,7 +1737,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::at(size_type __i) { @@ -1699,7 +1748,7 @@ deque<_Tp, _Allocator>::at(size_type __i) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::at(size_type __i) const { @@ -1710,7 +1759,7 @@ deque<_Tp, _Allocator>::at(size_type __i) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() { @@ -1719,7 +1768,7 @@ deque<_Tp, _Allocator>::front() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const { @@ -1728,7 +1777,7 @@ deque<_Tp, _Allocator>::front() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() { @@ -1737,7 +1786,7 @@ deque<_Tp, _Allocator>::back() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const { @@ -2029,7 +2078,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty if (__n > __front_spare()) __add_front_capacity(__n - __front_spare()); // __n <= __front_spare() - size_type __old_n = __n; iterator __old_begin = __base::begin(); iterator __i = __old_begin; if (__n > __pos) @@ -2054,7 +2102,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty if (__n > __back_capacity) __add_back_capacity(__n - __back_capacity); // __n <= __back_capacity - size_type __old_n = __n; iterator __old_end = __base::end(); iterator __i = __old_end; size_type __de = __base::size() - __pos; @@ -2119,7 +2166,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, if (__n > __front_spare()) __add_front_capacity(__n - __front_spare()); // __n <= __front_spare() - size_type __old_n = __n; iterator __old_begin = __base::begin(); iterator __i = __old_begin; _BiIter __m = __f; @@ -2150,7 +2196,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, if (__n > __back_capacity) __add_back_capacity(__n - __back_capacity); // __n <= __back_capacity - size_type __old_n = __n; iterator __old_end = __base::end(); iterator __i = __old_end; _BiIter __m = __l; @@ -2685,7 +2730,6 @@ template typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f) { - difference_type __n = 1; iterator __b = __base::begin(); difference_type __pos = __f - __b; iterator __p = __b + __pos; @@ -2781,7 +2825,7 @@ deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void deque<_Tp, _Allocator>::swap(deque& __c) #if _LIBCPP_STD_VER >= 14 @@ -2795,7 +2839,7 @@ deque<_Tp, _Allocator>::swap(deque& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void deque<_Tp, _Allocator>::clear() _NOEXCEPT { diff --git a/contrib/libc++/include/errno.h b/contrib/libc++/include/errno.h new file mode 100644 index 000000000000..ee6429110cc1 --- /dev/null +++ b/contrib/libc++/include/errno.h @@ -0,0 +1,398 @@ +// -*- C++ -*- +//===-------------------------- errno.h -----------------------------------===// +// +// 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_ERRNO_H +#define _LIBCPP_ERRNO_H + +/* + errno.h synopsis + +Macros: + + EDOM + EILSEQ // C99 + ERANGE + errno + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) + +#ifdef ELAST + +static const int __elast1 = ELAST+1; +static const int __elast2 = ELAST+2; + +#else + +static const int __elast1 = 104; +static const int __elast2 = 105; + +#endif + +#ifdef ENOTRECOVERABLE + +#define EOWNERDEAD __elast1 + +#ifdef ELAST +#undef ELAST +#define ELAST EOWNERDEAD +#endif + +#elif defined(EOWNERDEAD) + +#define ENOTRECOVERABLE __elast1 +#ifdef ELAST +#undef ELAST +#define ELAST ENOTRECOVERABLE +#endif + +#else // defined(EOWNERDEAD) + +#define EOWNERDEAD __elast1 +#define ENOTRECOVERABLE __elast2 +#ifdef ELAST +#undef ELAST +#define ELAST ENOTRECOVERABLE +#endif + +#endif // defined(EOWNERDEAD) + +#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) + +// supply errno values likely to be missing, particularly on Windows + +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 9901 +#endif + +#ifndef EADDRINUSE +#define EADDRINUSE 9902 +#endif + +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 9903 +#endif + +#ifndef EISCONN +#define EISCONN 9904 +#endif + +#ifndef EBADMSG +#define EBADMSG 9905 +#endif + +#ifndef ECONNABORTED +#define ECONNABORTED 9906 +#endif + +#ifndef EALREADY +#define EALREADY 9907 +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED 9908 +#endif + +#ifndef ECONNRESET +#define ECONNRESET 9909 +#endif + +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 9910 +#endif + +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 9911 +#endif + +#ifndef EIDRM +#define EIDRM 9912 +#endif + +#ifndef EMSGSIZE +#define EMSGSIZE 9913 +#endif + +#ifndef ENETDOWN +#define ENETDOWN 9914 +#endif + +#ifndef ENETRESET +#define ENETRESET 9915 +#endif + +#ifndef ENETUNREACH +#define ENETUNREACH 9916 +#endif + +#ifndef ENOBUFS +#define ENOBUFS 9917 +#endif + +#ifndef ENOLINK +#define ENOLINK 9918 +#endif + +#ifndef ENODATA +#define ENODATA 9919 +#endif + +#ifndef ENOMSG +#define ENOMSG 9920 +#endif + +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 9921 +#endif + +#ifndef ENOSR +#define ENOSR 9922 +#endif + +#ifndef ENOTSOCK +#define ENOTSOCK 9923 +#endif + +#ifndef ENOSTR +#define ENOSTR 9924 +#endif + +#ifndef ENOTCONN +#define ENOTCONN 9925 +#endif + +#ifndef ENOTSUP +#define ENOTSUP 9926 +#endif + +#ifndef ECANCELED +#define ECANCELED 9927 +#endif + +#ifndef EINPROGRESS +#define EINPROGRESS 9928 +#endif + +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 9929 +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 9930 +#endif + +#ifndef EOWNERDEAD +#define EOWNERDEAD 9931 +#endif + +#ifndef EPROTO +#define EPROTO 9932 +#endif + +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 9933 +#endif + +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE 9934 +#endif + +#ifndef ETIME +#define ETIME 9935 +#endif + +#ifndef ETXTBSY +#define ETXTBSY 9936 +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT 9938 +#endif + +#ifndef ELOOP +#define ELOOP 9939 +#endif + +#ifndef EOVERFLOW +#define EOVERFLOW 9940 +#endif + +#ifndef EPROTOTYPE +#define EPROTOTYPE 9941 +#endif + +#ifndef ENOSYS +#define ENOSYS 9942 +#endif + +#ifndef EINVAL +#define EINVAL 9943 +#endif + +#ifndef ERANGE +#define ERANGE 9944 +#endif + +#ifndef EILSEQ +#define EILSEQ 9945 +#endif + +// Windows Mobile doesn't appear to define these: + +#ifndef E2BIG +#define E2BIG 9946 +#endif + +#ifndef EDOM +#define EDOM 9947 +#endif + +#ifndef EFAULT +#define EFAULT 9948 +#endif + +#ifndef EBADF +#define EBADF 9949 +#endif + +#ifndef EPIPE +#define EPIPE 9950 +#endif + +#ifndef EXDEV +#define EXDEV 9951 +#endif + +#ifndef EBUSY +#define EBUSY 9952 +#endif + +#ifndef ENOTEMPTY +#define ENOTEMPTY 9953 +#endif + +#ifndef ENOEXEC +#define ENOEXEC 9954 +#endif + +#ifndef EEXIST +#define EEXIST 9955 +#endif + +#ifndef EFBIG +#define EFBIG 9956 +#endif + +#ifndef ENAMETOOLONG +#define ENAMETOOLONG 9957 +#endif + +#ifndef ENOTTY +#define ENOTTY 9958 +#endif + +#ifndef EINTR +#define EINTR 9959 +#endif + +#ifndef ESPIPE +#define ESPIPE 9960 +#endif + +#ifndef EIO +#define EIO 9961 +#endif + +#ifndef EISDIR +#define EISDIR 9962 +#endif + +#ifndef ECHILD +#define ECHILD 9963 +#endif + +#ifndef ENOLCK +#define ENOLCK 9964 +#endif + +#ifndef ENOSPC +#define ENOSPC 9965 +#endif + +#ifndef ENXIO +#define ENXIO 9966 +#endif + +#ifndef ENODEV +#define ENODEV 9967 +#endif + +#ifndef ENOENT +#define ENOENT 9968 +#endif + +#ifndef ESRCH +#define ESRCH 9969 +#endif + +#ifndef ENOTDIR +#define ENOTDIR 9970 +#endif + +#ifndef ENOMEM +#define ENOMEM 9971 +#endif + +#ifndef EPERM +#define EPERM 9972 +#endif + +#ifndef EACCES +#define EACCES 9973 +#endif + +#ifndef EROFS +#define EROFS 9974 +#endif + +#ifndef EDEADLK +#define EDEADLK 9975 +#endif + +#ifndef EAGAIN +#define EAGAIN 9976 +#endif + +#ifndef ENFILE +#define ENFILE 9977 +#endif + +#ifndef EMFILE +#define EMFILE 9978 +#endif + +#ifndef EMLINK +#define EMLINK 9979 +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_ERRNO_H diff --git a/contrib/libc++/include/exception b/contrib/libc++/include/exception index 5a905e7e58d8..686e4ecd0578 100644 --- a/contrib/libc++/include/exception +++ b/contrib/libc++/include/exception @@ -235,7 +235,7 @@ rethrow_if_nested(const _Ep& __e, typename enable_if< is_polymorphic<_Ep>::value >::type* = 0) { - const nested_exception* __nep = dynamic_cast(&__e); + const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) __nep->rethrow_nested(); } diff --git a/contrib/libc++/include/experimental/algorithm b/contrib/libc++/include/experimental/algorithm index a2e956f281a0..ffaa793b6d4e 100644 --- a/contrib/libc++/include/experimental/algorithm +++ b/contrib/libc++/include/experimental/algorithm @@ -50,6 +50,12 @@ SampleIterator sample(PopulationIterator first, PopulationIterator last, _LIBCPP_BEGIN_NAMESPACE_LFTS +template +_LIBCPP_INLINE_VISIBILITY +_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) +{ return __s(__f, __l); } + + template _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/experimental/any b/contrib/libc++/include/experimental/any new file mode 100644 index 000000000000..603788484dd5 --- /dev/null +++ b/contrib/libc++/include/experimental/any @@ -0,0 +1,590 @@ +// -*- C++ -*- +//===------------------------------ any -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ANY +#define _LIBCPP_EXPERIMENTAL_ANY + +/* + experimental/any synopsis + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + class bad_any_cast : public bad_cast + { + public: + virtual const char* what() const noexcept; + }; + + class any + { + public: + + // 6.3.1 any construct/destruct + any() noexcept; + + any(const any& other); + any(any&& other) noexcept; + + template + any(ValueType&& value); + + ~any(); + + // 6.3.2 any assignments + any& operator=(const any& rhs); + any& operator=(any&& rhs) noexcept; + + template + any& operator=(ValueType&& rhs); + + // 6.3.3 any modifiers + void clear() noexcept; + void swap(any& rhs) noexcept; + + // 6.3.4 any observers + bool empty() const noexcept; + const type_info& type() const noexcept; + }; + + // 6.4 Non-member functions + void swap(any& x, any& y) noexcept; + + template + ValueType any_cast(const any& operand); + template + ValueType any_cast(any& operand); + template + ValueType any_cast(any&& operand); + + template + const ValueType* any_cast(const any* operand) noexcept; + template + ValueType* any_cast(any* operand) noexcept; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include +#include +#include +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +{ +public: + virtual const char* what() const _NOEXCEPT; +}; + +#if _LIBCPP_STD_VER > 11 // C++ > 11 + +_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY +inline void __throw_bad_any_cast() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_any_cast(); +#else + assert(!"bad_any_cast"); +#endif +} + +// Forward declarations +class any; + +template +typename add_pointer::type>::type +any_cast(any const *) _NOEXCEPT; + +template +typename add_pointer<_ValueType>::type +any_cast(any *) _NOEXCEPT; + +namespace __any_imp +{ + typedef typename aligned_storage<3*sizeof(void*), alignment_of::value>::type + _Buffer; + + template + struct _IsSmallObject + : public integral_constant::value + % alignment_of<_Tp>::value == 0 + && is_nothrow_move_constructible<_Tp>::value + > + {}; + + enum class _Action + { + _Destroy, + _Copy, + _Move, + _Get, + _TypeInfo + }; + + template + struct _SmallHandler; + + template + struct _LargeHandler; + + template + using _Handler = typename conditional<_IsSmallObject<_Tp>::value + , _SmallHandler<_Tp> + , _LargeHandler<_Tp> + >::type; + template + using _EnableIfNotAny = typename + enable_if< + !is_same::type, any>::value + >::type; + +} // namespace __any_imp + +class any +{ +public: + // 6.3.1 any construct/destruct + _LIBCPP_INLINE_VISIBILITY + any() _NOEXCEPT : __h(nullptr) {} + + _LIBCPP_INLINE_VISIBILITY + any(any const & __other) : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Copy, this); + } + + _LIBCPP_INLINE_VISIBILITY + any(any && __other) _NOEXCEPT : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Move, this); + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + any(_ValueType && __value); + + _LIBCPP_INLINE_VISIBILITY + ~any() + { + this->clear(); + } + + // 6.3.2 any assignments + _LIBCPP_INLINE_VISIBILITY + any & operator=(any const & __rhs) + { + any(__rhs).swap(*this); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + any & operator=(any && __rhs) _NOEXCEPT + { + any(_VSTD::move(__rhs)).swap(*this); + return *this; + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + any & operator=(_ValueType && __rhs); + + // 6.3.3 any modifiers + _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + { + if (__h) this->__call(_Action::_Destroy); + } + + void swap(any & __rhs) _NOEXCEPT; + + // 6.3.4 any observers + _LIBCPP_INLINE_VISIBILITY + bool empty() const _NOEXCEPT + { + return __h == nullptr; + } + +#if !defined(_LIBCPP_NO_RTTI) + _LIBCPP_INLINE_VISIBILITY + const type_info & type() const _NOEXCEPT + { + if (__h) { + return *static_cast(this->__call(_Action::_TypeInfo)); + } else { + return typeid(void); + } + } +#endif + +private: + typedef __any_imp::_Action _Action; + + typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *); + + union _Storage + { + void * __ptr; + __any_imp::_Buffer __buf; + }; + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) const + { + return __h(__a, this, __other, __info); + } + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) + { + return __h(__a, this, __other, __info); + } + + template + friend struct __any_imp::_SmallHandler; + template + friend struct __any_imp::_LargeHandler; + + template + friend typename add_pointer::type>::type + any_cast(any const *) _NOEXCEPT; + + template + friend typename add_pointer<_ValueType>::type + any_cast(any *) _NOEXCEPT; + + _HandleFuncPtr __h; + _Storage __s; +}; + +namespace __any_imp +{ + + template + struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + ::new (static_cast(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__h = &_SmallHandler::__handle; + } + + private: + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + _Tp & __value = *static_cast<_Tp *>(static_cast(&__this.__s.__buf)); + __value.~_Tp(); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _SmallHandler::__create(__dest, *static_cast<_Tp const *>( + static_cast(&__this.__s.__buf))); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + _SmallHandler::__create(__dest, _VSTD::move( + *static_cast<_Tp*>(static_cast(&__this.__s.__buf)))); + __destroy(__this); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast(&__this.__s.__buf); + } + return nullptr; +#else + return static_cast(&__this.__s.__buf); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast(static_cast(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + + template + struct _LIBCPP_TYPE_VIS_ONLY _LargeHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + typedef allocator<_Tp> _Alloc; + typedef __allocator_destructor<_Alloc> _Dp; + _Alloc __a; + unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__s.__ptr = __hold.release(); + __dest.__h = &_LargeHandler::__handle; + } + + private: + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + delete static_cast<_Tp*>(__this.__s.__ptr); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr)); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + __dest.__s.__ptr = __this.__s.__ptr; + __dest.__h = &_LargeHandler::__handle; + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast(__this.__s.__ptr); + } + return nullptr; +#else + return static_cast(__this.__s.__ptr); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast(static_cast(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + +} // namespace __any_imp + + +template +_LIBCPP_INLINE_VISIBILITY +any::any(_ValueType && __v) : __h(nullptr) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + typedef __any_imp::_Handler<_Tp> _HandlerType; + _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v)); +} + +template +_LIBCPP_INLINE_VISIBILITY +any & any::operator=(_ValueType && __v) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + any(_VSTD::forward<_ValueType>(__v)).swap(*this); + return *this; +} + +inline _LIBCPP_INLINE_VISIBILITY +void any::swap(any & __rhs) _NOEXCEPT +{ + if (__h && __rhs.__h) { + any __tmp; + __rhs.__call(_Action::_Move, &__tmp); + this->__call(_Action::_Move, &__rhs); + __tmp.__call(_Action::_Move, this); + } + else if (__h) { + this->__call(_Action::_Move, &__rhs); + } + else if (__rhs.__h) { + __rhs.__call(_Action::_Move, this); + } +} + +// 6.4 Non-member functions + +inline _LIBCPP_INLINE_VISIBILITY +void swap(any & __lhs, any & __rhs) _NOEXCEPT +{ + __lhs.swap(__rhs); +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any const & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename add_const::type>::type + _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any && __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename add_pointer::type>::type +any_cast(any const * __any) _NOEXCEPT +{ + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + return any_cast<_ValueType>(const_cast(__any)); +} + +template +_LIBCPP_INLINE_VISIBILITY +typename add_pointer<_ValueType>::type +any_cast(any * __any) _NOEXCEPT +{ + using __any_imp::_Action; + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + typedef typename add_pointer<_ValueType>::type _ReturnType; + if (__any && __any->__h) { + + return static_cast<_ReturnType>( + __any->__call(_Action::_Get, nullptr, +#if !defined(_LIBCPP_NO_RTTI) + &typeid(_ValueType) +#else + nullptr +#endif + )); + + } + return nullptr; +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif // _LIBCPP_EXPERIMENTAL_ANY diff --git a/contrib/libc++/include/experimental/dynarray b/contrib/libc++/include/experimental/dynarray index a0258628dfa6..f40a6ca188b8 100644 --- a/contrib/libc++/include/experimental/dynarray +++ b/contrib/libc++/include/experimental/dynarray @@ -137,7 +137,7 @@ public: private: size_t __size_; value_type * __base_; - _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {} + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {} static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) { diff --git a/contrib/libc++/include/experimental/functional b/contrib/libc++/include/experimental/functional new file mode 100644 index 000000000000..c7a78695b809 --- /dev/null +++ b/contrib/libc++/include/experimental/functional @@ -0,0 +1,454 @@ +// -*- C++ -*- +//===-------------------------- functional --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL +#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL + +/* + experimental/functional synopsis + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.9.9, Function object binders + template constexpr bool is_bind_expression_v + = is_bind_expression::value; + template constexpr int is_placeholder_v + = is_placeholder::value; + + // 4.2, Class template function + template class function; // undefined + template class function; + + template + void swap(function&, function&); + + template + bool operator==(const function&, nullptr_t) noexcept; + template + bool operator==(nullptr_t, const function&) noexcept; + template + bool operator!=(const function&, nullptr_t) noexcept; + template + bool operator!=(nullptr_t, const function&) noexcept; + + // 4.3, Searchers + template> + class default_searcher; + + template::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_searcher; + + template::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_horspool_searcher; + + template> + default_searcher + make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, + BinaryPredicate pred = BinaryPredicate()); + + template::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_searcher + make_boyer_moore_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + template::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_horspool_searcher + make_boyer_moore_horspool_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + } // namespace fundamentals_v1 + } // namespace experimental + + template + struct uses_allocator, Alloc>; + +} // namespace std + +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include <__undef_min_max> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if _LIBCPP_STD_VER > 11 +// default searcher +template> +_LIBCPP_TYPE_VIS +class default_searcher { +public: + _LIBCPP_INLINE_VISIBILITY + default_searcher(_ForwardIterator __f, _ForwardIterator __l, + _BinaryPredicate __p = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__p) {} + + template + _LIBCPP_INLINE_VISIBILITY + _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + { + return _VSTD::search(__f, __l, __first_, __last_, __pred_); + } + +private: + _ForwardIterator __first_; + _ForwardIterator __last_; + _BinaryPredicate __pred_; + }; + +template> +_LIBCPP_INLINE_VISIBILITY +default_searcher<_ForwardIterator, _BinaryPredicate> +make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ()) +{ + return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p); +} + +template class _BMSkipTable; + +// General case for BM data searching; use a map +template +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> { +public: // TODO private: + typedef _Value value_type; + typedef _Key key_type; + + const _Value __default_value_; + std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred) + : __default_value_(__default), __table(__sz, __hf, __pred) {} + + _LIBCPP_INLINE_VISIBILITY + void insert(const key_type &__key, value_type __val) + { + __table [__key] = __val; // Would skip_.insert (val) be better here? + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](const key_type & __key) const + { + auto __it = __table.find (__key); + return __it == __table.end() ? __default_value_ : __it->second; + } +}; + + +// Special case small numeric values; use an array +template +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> { +private: + typedef _Value value_type; + typedef _Key key_type; + + typedef typename std::make_unsigned::type unsigned_key_type; + typedef std::array::max()> skip_map; + skip_map __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/) + { + std::fill_n(__table.begin(), __table.size(), __default); + } + + _LIBCPP_INLINE_VISIBILITY + void insert(key_type __key, value_type __val) + { + __table[static_cast(__key)] = __val; + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](key_type __key) const + { + return __table[static_cast(__key)]; + } +}; + + +template ::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{make_shared(__pattern_length_, -1, __hf, __pred_)}, + __suffix_{make_shared>(__pattern_length_ + 1)} + { + // build the skip table + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __i); + + this->__build_suffix_table ( __first_, __last_, __pred_ ); + } + + template + _RandomAccessIterator2 + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay::value_type>::type, + typename std::decay::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return __l; // empty corpus + if (__first_ == __last_) return __f; // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return __l; + + // Do the search + return this->__search(__f, __l); + } + +public: // TODO private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr __skip_; + shared_ptr> __suffix_; + + template + _RandomAccessIterator2 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + const vector & __suffix = *__suffix_.get(); + + while (__cur <= __last) + { + + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_ [__j-1], __cur [__j-1])) { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return __cur; + } + + // Since we didn't match, figure out how far to skip forward + difference_type __k = __skip[__cur [ __j - 1 ]]; + difference_type __m = __j - __k - 1; + if (__k < __j && __m > __suffix[ __j ]) + __cur += __m; + else + __cur += __suffix[ __j ]; + } + + return __l; // We didn't find anything + } + + + template + void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix ) + { + const std::size_t __count = _VSTD::distance(__f, __l); + + __prefix[0] = 0; + std::size_t __k = 0; + for ( std::size_t __i = 1; __i < __count; ++__i ) + { + while ( __k > 0 && !__pred ( __f[__k], __f[__i] )) + __k = __prefix [ __k - 1 ]; + + if ( __pred ( __f[__k], __f[__i] )) + __k++; + __prefix [ __i ] = __k; + } + } + + void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _BinaryPredicate __pred) + { + const std::size_t __count = _VSTD::distance(__f, __l); + vector & __suffix = *__suffix_.get(); + if (__count > 0) + { + _VSTD::vector __scratch(__count); + + __compute_bm_prefix(__f, __l, __pred, __scratch); + for ( std::size_t __i = 0; __i <= __count; __i++ ) + __suffix[__i] = __count - __scratch[__count-1]; + + typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter; + __compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch); + + for ( std::size_t __i = 0; __i < __count; __i++ ) + { + const std::size_t __j = __count - __scratch[__i]; + const difference_type __k = __i - __scratch[__i] + 1; + + if (__suffix[__j] > __k) + __suffix[__j] = __k; + } + } + } + +}; + +template::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +// boyer-moore-horspool +template ::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_horspool_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{_VSTD::make_shared(__pattern_length_, __pattern_length_, __hf, __pred_)} + { + // build the skip table + if ( __f != __l ) + { + __l = __l - 1; + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __pattern_length_ - 1 - __i); + } + } + + template + _RandomAccessIterator2 + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay::value_type>::type, + typename std::decay::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return __l; // empty corpus + if (__first_ == __last_) return __f; // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return __l; + + // Do the search + return this->__search(__f, __l); + } + +private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr __skip_; + + template + _RandomAccessIterator2 __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + + while (__cur <= __last) + { + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_[__j-1], __cur[__j-1])) + { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return __cur; + } + __cur += __skip[__cur[__pattern_length_-1]]; + } + + return __l; + } +}; + +template::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/contrib/libc++/include/ext/hash_map b/contrib/libc++/include/ext/hash_map index 31fcedfb9f9e..3ac27b2ca330 100644 --- a/contrib/libc++/include/ext/hash_map +++ b/contrib/libc++/include/ext/hash_map @@ -368,7 +368,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::first_type key_type; typedef typename _HashIterator::value_type::second_type mapped_type; public: @@ -376,13 +375,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {} @@ -419,7 +413,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::first_type key_type; typedef typename _HashIterator::value_type::second_type mapped_type; public: @@ -427,13 +420,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {} @@ -681,7 +669,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template diff --git a/contrib/libc++/include/float.h b/contrib/libc++/include/float.h new file mode 100644 index 000000000000..1acfdc6188f2 --- /dev/null +++ b/contrib/libc++/include/float.h @@ -0,0 +1,83 @@ +// -*- C++ -*- +//===--------------------------- float.h ----------------------------------===// +// +// 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_FLOAT_H +#define _LIBCPP_FLOAT_H + +/* + float.h synopsis + +Macros: + + FLT_ROUNDS + FLT_EVAL_METHOD // C99 + FLT_RADIX + + FLT_MANT_DIG + DBL_MANT_DIG + LDBL_MANT_DIG + + DECIMAL_DIG // C99 + + FLT_DIG + DBL_DIG + LDBL_DIG + + FLT_MIN_EXP + DBL_MIN_EXP + LDBL_MIN_EXP + + FLT_MIN_10_EXP + DBL_MIN_10_EXP + LDBL_MIN_10_EXP + + FLT_MAX_EXP + DBL_MAX_EXP + LDBL_MAX_EXP + + FLT_MAX_10_EXP + DBL_MAX_10_EXP + LDBL_MAX_10_EXP + + FLT_MAX + DBL_MAX + LDBL_MAX + + FLT_EPSILON + DBL_EPSILON + LDBL_EPSILON + + FLT_MIN + DBL_MIN + LDBL_MIN + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#ifndef FLT_EVAL_METHOD +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif + +#ifndef DECIMAL_DIG +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_FLOAT_H diff --git a/contrib/libc++/include/forward_list b/contrib/libc++/include/forward_list index 8a87fc5e1f26..4f9ecf49bd58 100644 --- a/contrib/libc++/include/forward_list +++ b/contrib/libc++/include/forward_list @@ -197,15 +197,9 @@ struct __forward_begin_node template struct _LIBCPP_HIDDEN __begin_node_of { - typedef __forward_begin_node - < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__forward_list_node<_Tp, _VoidPtr> > -#else - rebind<__forward_list_node<_Tp, _VoidPtr> >::other -#endif - > type; + typedef __forward_begin_node< + typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type + > type; }; template @@ -240,13 +234,7 @@ public: typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} @@ -295,13 +283,7 @@ class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator < typename pointer_traits<__node_const_pointer>::element_type >::type __node; - typedef typename pointer_traits<__node_const_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__node> -#else - rebind<__node>::other -#endif - __node_pointer; + typedef typename __rebind_pointer<__node_const_pointer, __node>::type __node_pointer; template friend class forward_list; @@ -311,13 +293,7 @@ public: typedef const value_type& reference; typedef typename pointer_traits<__node_const_pointer>::difference_type difference_type; - typedef typename pointer_traits<__node_const_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_const_pointer, const value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} @@ -537,6 +513,9 @@ public: typedef _Tp value_type; typedef _Alloc allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef value_type& reference; typedef const value_type& const_reference; typedef typename allocator_traits::pointer pointer; diff --git a/contrib/libc++/include/functional b/contrib/libc++/include/functional index 9bed783153ef..dbe9b01bbd86 100644 --- a/contrib/libc++/include/functional +++ b/contrib/libc++/include/functional @@ -1234,11 +1234,9 @@ const_mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} -#ifdef _LIBCPP_HAS_NO_VARIADICS - -#include <__functional_03> - -#else // _LIBCPP_HAS_NO_VARIADICS +//////////////////////////////////////////////////////////////////////////////// +// MEMFUN +//============================================================================== template class __mem_fn @@ -1251,26 +1249,130 @@ private: type __f_; public: - _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} + _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} +#ifndef _LIBCPP_HAS_NO_VARIADICS // invoke template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() (_ArgTypes&&... __args) const - { - return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return::type + operator() (_ArgTypes&&... __args) const { + return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); + } +#else + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return __invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return __invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } +#endif }; template inline _LIBCPP_INLINE_VISIBILITY __mem_fn<_Rp _Tp::*> -mem_fn(_Rp _Tp::* __pm) +mem_fn(_Rp _Tp::* __pm) _NOEXCEPT { return __mem_fn<_Rp _Tp::*>(__pm); } +//////////////////////////////////////////////////////////////////////////////// +// FUNCTION +//============================================================================== + // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -1283,7 +1385,7 @@ template class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { -template +template struct __maybe_derive_from_unary_function { }; @@ -1294,7 +1396,7 @@ struct __maybe_derive_from_unary_function<_Rp(_A1)> { }; -template +template struct __maybe_derive_from_binary_function { }; @@ -1305,6 +1407,28 @@ struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> { }; +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Fp const&) { return true; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Fp* __ptr) { return __ptr; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Ret _Class::*__ptr) { return __ptr; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(function<_Fp> const& __f) { return !!__f; } + +} // namespace __function + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +namespace __function { + template class __base; template @@ -1440,28 +1564,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;} - template ::value && __invokable<_Fp&, _ArgTypes...>::value> struct __callable; @@ -1626,7 +1728,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f, >::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) @@ -1653,7 +1755,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _ : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; @@ -1848,6 +1950,16 @@ void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} +#else // _LIBCPP_HAS_NO_VARIADICS + +#include <__functional_03> + +#endif + +//////////////////////////////////////////////////////////////////////////////// +// BIND +//============================================================================== + template struct __is_bind_expression : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression::type> {}; @@ -1878,6 +1990,9 @@ template struct __is_placeholder > : public integral_constant {}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + template inline _LIBCPP_INLINE_VISIBILITY _Tp& diff --git a/contrib/libc++/include/future b/contrib/libc++/include/future index 5b5afe6e2771..ce15eafbf7e4 100644 --- a/contrib/libc++/include/future +++ b/contrib/libc++/include/future @@ -512,6 +512,16 @@ public: virtual ~future_error() _NOEXCEPT; }; +inline _LIBCPP_ALWAYS_INLINE +void __throw_future_error(future_errc _Ev) +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw future_error(make_error_code(_Ev)); +#else + assert(!"future_error"); +#endif +} + class _LIBCPP_TYPE_VIS __assoc_sub_state : public __shared_count { @@ -566,6 +576,7 @@ public: void wait(); template future_status + _LIBCPP_INLINE_VISIBILITY wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; template future_status @@ -589,7 +600,7 @@ __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs } template -inline _LIBCPP_INLINE_VISIBILITY +inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { @@ -645,10 +656,8 @@ __assoc_state<_Rp>::set_value(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); @@ -664,10 +673,8 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); @@ -725,10 +732,8 @@ void __assoc_state<_Rp&>::set_value(_Rp& __arg) { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); @@ -739,10 +744,8 @@ void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); @@ -849,6 +852,7 @@ class __deferred_assoc_state public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif @@ -858,7 +862,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -895,6 +899,7 @@ class __deferred_assoc_state public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif @@ -904,7 +909,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -943,6 +948,7 @@ class __async_assoc_state virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif @@ -952,7 +958,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -997,6 +1003,7 @@ class __async_assoc_state virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif @@ -1006,7 +1013,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -1108,6 +1115,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future<_Rp> share(); // retrieving the value @@ -1138,10 +1146,8 @@ template future<_Rp>::future(__assoc_state<_Rp>* __state) : __state_(__state) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_->__has_future_attached()) - throw future_error(make_error_code(future_errc::future_already_retrieved)); -#endif + __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } @@ -1212,6 +1218,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future<_Rp&> share(); // retrieving the value @@ -1242,10 +1249,8 @@ template future<_Rp&>::future(__assoc_state<_Rp&>* __state) : __state_(__state) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_->__has_future_attached()) - throw future_error(make_error_code(future_errc::future_already_retrieved)); -#endif + __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } @@ -1311,6 +1316,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future share(); // retrieving the value @@ -1445,10 +1451,8 @@ template future<_Rp> promise<_Rp>::get_future() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); return future<_Rp>(__state_); } @@ -1456,10 +1460,8 @@ template void promise<_Rp>::set_value(const _Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(__r); } @@ -1469,10 +1471,8 @@ template void promise<_Rp>::set_value(_Rp&& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(_VSTD::move(__r)); } @@ -1482,10 +1482,8 @@ template void promise<_Rp>::set_exception(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } @@ -1493,10 +1491,8 @@ template void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } @@ -1506,10 +1502,8 @@ template void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(_VSTD::move(__r)); } @@ -1519,10 +1513,8 @@ template void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } @@ -1619,10 +1611,8 @@ template future<_Rp&> promise<_Rp&>::get_future() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); return future<_Rp&>(__state_); } @@ -1630,10 +1620,8 @@ template void promise<_Rp&>::set_value(_Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(__r); } @@ -1641,10 +1629,8 @@ template void promise<_Rp&>::set_exception(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } @@ -1652,10 +1638,8 @@ template void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } @@ -1663,10 +1647,8 @@ template void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } @@ -1861,6 +1843,7 @@ public: void swap(__packaged_task_function&) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _Rp operator()(_ArgTypes...) const; }; @@ -2000,7 +1983,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { @@ -2087,11 +2070,11 @@ template void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2109,11 +2092,11 @@ template void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2131,10 +2114,8 @@ template void packaged_task<_Rp(_ArgTypes...)>::reset() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!valid()) - throw future_error(make_error_code(future_errc::no_state)); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_future_error(future_errc::no_state); __p_ = promise(); } @@ -2218,11 +2199,11 @@ template void packaged_task::operator()(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2241,11 +2222,11 @@ template void packaged_task::make_ready_at_thread_exit(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2264,10 +2245,8 @@ template void packaged_task::reset() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!valid()) - throw future_error(make_error_code(future_errc::no_state)); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_future_error(future_errc::no_state); __p_ = promise(); } @@ -2592,7 +2571,7 @@ swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future<_Rp> future<_Rp>::share() { @@ -2600,7 +2579,7 @@ future<_Rp>::share() } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future<_Rp&> future<_Rp&>::share() { @@ -2609,7 +2588,7 @@ future<_Rp&>::share() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future future::share() { diff --git a/contrib/libc++/include/inttypes.h b/contrib/libc++/include/inttypes.h new file mode 100644 index 000000000000..5c5618bef884 --- /dev/null +++ b/contrib/libc++/include/inttypes.h @@ -0,0 +1,251 @@ +// -*- C++ -*- +//===--------------------------- inttypes.h -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_INTTYPES_H +#define _LIBCPP_INTTYPES_H + +/* + inttypes.h synopsis + +This entire header is C99 / C++0X + +#include // includes + +Macros: + + PRId8 + PRId16 + PRId32 + PRId64 + + PRIdLEAST8 + PRIdLEAST16 + PRIdLEAST32 + PRIdLEAST64 + + PRIdFAST8 + PRIdFAST16 + PRIdFAST32 + PRIdFAST64 + + PRIdMAX + PRIdPTR + + PRIi8 + PRIi16 + PRIi32 + PRIi64 + + PRIiLEAST8 + PRIiLEAST16 + PRIiLEAST32 + PRIiLEAST64 + + PRIiFAST8 + PRIiFAST16 + PRIiFAST32 + PRIiFAST64 + + PRIiMAX + PRIiPTR + + PRIo8 + PRIo16 + PRIo32 + PRIo64 + + PRIoLEAST8 + PRIoLEAST16 + PRIoLEAST32 + PRIoLEAST64 + + PRIoFAST8 + PRIoFAST16 + PRIoFAST32 + PRIoFAST64 + + PRIoMAX + PRIoPTR + + PRIu8 + PRIu16 + PRIu32 + PRIu64 + + PRIuLEAST8 + PRIuLEAST16 + PRIuLEAST32 + PRIuLEAST64 + + PRIuFAST8 + PRIuFAST16 + PRIuFAST32 + PRIuFAST64 + + PRIuMAX + PRIuPTR + + PRIx8 + PRIx16 + PRIx32 + PRIx64 + + PRIxLEAST8 + PRIxLEAST16 + PRIxLEAST32 + PRIxLEAST64 + + PRIxFAST8 + PRIxFAST16 + PRIxFAST32 + PRIxFAST64 + + PRIxMAX + PRIxPTR + + PRIX8 + PRIX16 + PRIX32 + PRIX64 + + PRIXLEAST8 + PRIXLEAST16 + PRIXLEAST32 + PRIXLEAST64 + + PRIXFAST8 + PRIXFAST16 + PRIXFAST32 + PRIXFAST64 + + PRIXMAX + PRIXPTR + + SCNd8 + SCNd16 + SCNd32 + SCNd64 + + SCNdLEAST8 + SCNdLEAST16 + SCNdLEAST32 + SCNdLEAST64 + + SCNdFAST8 + SCNdFAST16 + SCNdFAST32 + SCNdFAST64 + + SCNdMAX + SCNdPTR + + SCNi8 + SCNi16 + SCNi32 + SCNi64 + + SCNiLEAST8 + SCNiLEAST16 + SCNiLEAST32 + SCNiLEAST64 + + SCNiFAST8 + SCNiFAST16 + SCNiFAST32 + SCNiFAST64 + + SCNiMAX + SCNiPTR + + SCNo8 + SCNo16 + SCNo32 + SCNo64 + + SCNoLEAST8 + SCNoLEAST16 + SCNoLEAST32 + SCNoLEAST64 + + SCNoFAST8 + SCNoFAST16 + SCNoFAST32 + SCNoFAST64 + + SCNoMAX + SCNoPTR + + SCNu8 + SCNu16 + SCNu32 + SCNu64 + + SCNuLEAST8 + SCNuLEAST16 + SCNuLEAST32 + SCNuLEAST64 + + SCNuFAST8 + SCNuFAST16 + SCNuFAST32 + SCNuFAST64 + + SCNuMAX + SCNuPTR + + SCNx8 + SCNx16 + SCNx32 + SCNx64 + + SCNxLEAST8 + SCNxLEAST16 + SCNxLEAST32 + SCNxLEAST64 + + SCNxFAST8 + SCNxFAST16 + SCNxFAST32 + SCNxFAST64 + + SCNxMAX + SCNxPTR + +Types: + + imaxdiv_t + +intmax_t imaxabs(intmax_t j); +imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); +intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base); +uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base); +intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#include + +#undef imaxabs +#undef imaxdiv + +#endif // __cplusplus + +#endif // _LIBCPP_INTTYPES_H diff --git a/contrib/libc++/include/ios b/contrib/libc++/include/ios index ff79998b0bbf..1deb5f613c8a 100644 --- a/contrib/libc++/include/ios +++ b/contrib/libc++/include/ios @@ -114,9 +114,9 @@ class basic_ios public: // types: typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; + typedef typename traits::int_type int_type; // removed in C++17 + typedef typename traits::pos_type pos_type; // removed in C++17 + typedef typename traits::off_type off_type; // removed in C++17 typedef traits traits_type; operator unspecified-bool-type() const; @@ -216,7 +216,7 @@ storage-class-specifier const error_category& iostream_category() noexcept; #include <__locale> #include -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) #include // for __xindex_ #endif @@ -254,14 +254,12 @@ public: static const fmtflags floatfield = scientific | fixed; typedef unsigned int iostate; - typedef iostate io_state; static const iostate badbit = 0x1; static const iostate eofbit = 0x2; static const iostate failbit = 0x4; static const iostate goodbit = 0x0; typedef unsigned int openmode; - typedef openmode open_mode; static const openmode app = 0x01; static const openmode ate = 0x02; static const openmode binary = 0x04; @@ -270,10 +268,15 @@ public: static const openmode trunc = 0x20; enum seekdir {beg, cur, end}; - typedef seekdir seek_dir; + +#if _LIBCPP_STD_VER <= 14 + typedef iostate io_state; + typedef openmode open_mode; + typedef seekdir seek_dir; typedef _VSTD::streamoff streamoff; typedef _VSTD::streampos streampos; +#endif class _LIBCPP_TYPE_VIS Init; @@ -367,7 +370,9 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only +// enabled with clang. +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic __xindex_; #else static int __xindex_; diff --git a/contrib/libc++/include/istream b/contrib/libc++/include/istream index 168a4d0635f6..0bcc7eeaf639 100644 --- a/contrib/libc++/include/istream +++ b/contrib/libc++/include/istream @@ -1407,6 +1407,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) try { #endif // _LIBCPP_NO_EXCEPTIONS + this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { diff --git a/contrib/libc++/include/iterator b/contrib/libc++/include/iterator index c06ef8f6777d..8d9b31101bdf 100644 --- a/contrib/libc++/include/iterator +++ b/contrib/libc++/include/iterator @@ -437,6 +437,12 @@ struct __is_bidirectional_iterator : public __has_iterator_category_convertible_ template struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; +template +struct __is_exactly_input_iterator + : public integral_constant::value && + !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; + template struct _LIBCPP_TYPE_VIS_ONLY iterator @@ -513,12 +519,12 @@ distance(_InputIter __first, _InputIter __last) return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } -template +template inline _LIBCPP_INLINE_VISIBILITY -_ForwardIter -next(_ForwardIter __x, - typename iterator_traits<_ForwardIter>::difference_type __n = 1, - typename enable_if<__is_forward_iterator<_ForwardIter>::value>::type* = 0) +_InputIter +next(_InputIter __x, + typename iterator_traits<_InputIter>::difference_type __n = 1, + typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0) { _VSTD::advance(__x, __n); return __x; @@ -1404,6 +1410,23 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } +template +struct __libcpp_is_trivial_iterator + : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp* diff --git a/contrib/libc++/include/limits b/contrib/libc++/include/limits index ce967ea1b239..80a1be40fe47 100644 --- a/contrib/libc++/include/limits +++ b/contrib/libc++/include/limits @@ -237,7 +237,8 @@ protected: static _LIBCPP_CONSTEXPR const bool is_bounded = true; static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value; -#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) +#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \ + defined(__wasm__) static _LIBCPP_CONSTEXPR const bool traps = true; #else static _LIBCPP_CONSTEXPR const bool traps = false; diff --git a/contrib/libc++/include/list b/contrib/libc++/include/list index 14201a80e348..44b20e2fa28c 100644 --- a/contrib/libc++/include/list +++ b/contrib/libc++/include/list @@ -175,6 +175,7 @@ template #include #include #include +#include #include <__undef_min_max> @@ -187,34 +188,66 @@ template _LIBCPP_BEGIN_NAMESPACE_STD template struct __list_node; +template struct __list_node_base; + +template +struct __list_node_pointer_traits { + typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type + __node_pointer; + typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type + __base_pointer; + +#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB) + typedef __base_pointer __link_pointer; +#else + typedef typename conditional< + is_pointer<_VoidPtr>::value, + __base_pointer, + __node_pointer + >::type __link_pointer; +#endif + + typedef typename conditional< + is_same<__link_pointer, __node_pointer>::value, + __base_pointer, + __node_pointer + >::type __non_link_pointer; + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { + return __p; + } + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) { + return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p)); + } + +}; template struct __list_node_base { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other pointer; -#endif + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__node_pointer __node_pointer; + typedef typename _NodeTraits::__base_pointer __base_pointer; + typedef typename _NodeTraits::__link_pointer __link_pointer; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node_base> __base_pointer; -#else - rebind<__list_node_base>::other __base_pointer; -#endif - - pointer __prev_; - pointer __next_; + __link_pointer __prev_; + __link_pointer __next_; _LIBCPP_INLINE_VISIBILITY - __list_node_base() : __prev_(__self()), __next_(__self()) {} + __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), + __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} _LIBCPP_INLINE_VISIBILITY - pointer __self() - { - return static_cast(pointer_traits<__base_pointer>::pointer_to(*this)); + __base_pointer __self() { + return pointer_traits<__base_pointer>::pointer_to(*this); + } + + _LIBCPP_INLINE_VISIBILITY + __node_pointer __as_node() { + return static_cast<__node_pointer>(__self()); } }; @@ -223,6 +256,14 @@ struct __list_node : public __list_node_base<_Tp, _VoidPtr> { _Tp __value_; + + typedef __list_node_base<_Tp, _VoidPtr> __base; + typedef typename __base::__link_pointer __link_pointer; + + _LIBCPP_INLINE_VISIBILITY + __link_pointer __as_link() { + return static_cast<__link_pointer>(__base::__self()); + } }; template > class _LIBCPP_TYPE_VIS_ONLY list; @@ -232,25 +273,21 @@ template class _LIBCPP_TYPE_VIS_ONLY __list_const_it template class _LIBCPP_TYPE_VIS_ONLY __list_iterator { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > __node_pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer; -#endif + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__link_pointer __link_pointer; - __node_pointer __ptr_; + __link_pointer __ptr_; #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - explicit __list_iterator(__node_pointer __p, const void* __c) _NOEXCEPT + explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT : __ptr_(__p) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY - explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} #endif @@ -262,13 +299,7 @@ public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef value_type& reference; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer; typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY @@ -314,7 +345,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return __ptr_->__value_; + return __ptr_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -323,7 +354,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return pointer_traits::pointer_to(__ptr_->__value_); + return pointer_traits::pointer_to(__ptr_->__as_node()->__value_); } _LIBCPP_INLINE_VISIBILITY @@ -365,25 +396,21 @@ public: template class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > __node_pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer; -#endif + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__link_pointer __link_pointer; - __node_pointer __ptr_; + __link_pointer __ptr_; #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - explicit __list_const_iterator(__node_pointer __p, const void* __c) _NOEXCEPT + explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT : __ptr_(__p) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY - explicit __list_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} #endif template friend class list; @@ -392,13 +419,7 @@ public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef const value_type& reference; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer; typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY @@ -451,7 +472,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::const_iterator"); #endif - return __ptr_->__value_; + return __ptr_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -460,7 +481,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return pointer_traits::pointer_to(__ptr_->__value_); + return pointer_traits::pointer_to(__ptr_->__as_node()->__value_); } _LIBCPP_INLINE_VISIBILITY @@ -518,6 +539,9 @@ protected: typedef allocator_traits<__node_allocator> __node_alloc_traits; typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; + typedef __list_node_pointer_traits __node_pointer_traits; + typedef typename __node_pointer_traits::__link_pointer __link_pointer; + typedef __link_pointer __link_const_pointer; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::difference_type difference_type; @@ -528,6 +552,12 @@ protected: __node_base __end_; __compressed_pair __size_alloc_; + _LIBCPP_INLINE_VISIBILITY + __link_pointer __end_as_link() const _NOEXCEPT { + return __node_pointer_traits::__unsafe_link_pointer_cast( + const_cast<__node_base&>(__end_).__self()); + } + _LIBCPP_INLINE_VISIBILITY size_type& __sz() _NOEXCEPT {return __size_alloc_.first();} _LIBCPP_INLINE_VISIBILITY @@ -540,7 +570,7 @@ protected: const __node_allocator& __node_alloc() const _NOEXCEPT {return __size_alloc_.second();} - static void __unlink_nodes(__node_pointer __f, __node_pointer __l) _NOEXCEPT; + static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT; __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); @@ -572,22 +602,18 @@ protected: iterator end() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)), this); + return iterator(__end_as_link(), this); #else - return iterator(static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_))); + return iterator(__end_as_link()); #endif } _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(static_cast<__node_const_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))), this); + return const_iterator(__end_as_link(), this); #else - return const_iterator(static_cast<__node_const_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_)))); + return const_iterator(__end_as_link()); #endif } @@ -642,7 +668,7 @@ private: template inline _LIBCPP_INLINE_VISIBILITY void -__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l) +__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT { __f->__prev_->__next_ = __l->__next_; @@ -680,17 +706,16 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT if (!empty()) { __node_allocator& __na = __node_alloc(); - __node_pointer __f = __end_.__next_; - __node_pointer __l = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)); + __link_pointer __f = __end_.__next_; + __link_pointer __l = __end_as_link(); __unlink_nodes(__f, __l->__prev_); __sz() = 0; while (__f != __l) { - __node_pointer __n = __f; + __node_pointer __np = __f->__as_node(); __f = __f->__next_; - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); @@ -729,13 +754,13 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) swap(__sz(), __c.__sz()); swap(__end_, __c.__end_); if (__sz() == 0) - __end_.__next_ = __end_.__prev_ = __end_.__self(); + __end_.__next_ = __end_.__prev_ = __end_as_link(); else - __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self(); + __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link(); if (__c.__sz() == 0) - __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self(); + __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link(); else - __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self(); + __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link(); #if _LIBCPP_DEBUG_LEVEL >= 2 __libcpp_db* __db = __get_db(); @@ -748,8 +773,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) { --__p; const_iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ == static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ == __c.__end_as_link()) { __cn2->__add(*__p); if (--__cn1->end_ != __p) @@ -762,8 +786,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) { --__p; const_iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ == static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_))) + if (__i->__ptr_ == __end_as_link()) { __cn1->__add(*__p); if (--__cn2->end_ != __p) @@ -787,6 +810,7 @@ class _LIBCPP_TYPE_VIS_ONLY list typedef typename base::__node_alloc_traits __node_alloc_traits; typedef typename base::__node_base __node_base; typedef typename base::__node_base_pointer __node_base_pointer; + typedef typename base::__link_pointer __link_pointer; public: typedef _Tp value_type; @@ -910,25 +934,25 @@ public: reference front() { _LIBCPP_ASSERT(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__value_; + return base::__end_.__next_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY const_reference front() const { _LIBCPP_ASSERT(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__value_; + return base::__end_.__next_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY reference back() { _LIBCPP_ASSERT(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__value_; + return base::__end_.__prev_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY const_reference back() const { _LIBCPP_ASSERT(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__value_; + return base::__end_.__prev_->__as_node()->__value_; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1033,9 +1057,9 @@ public: #endif // _LIBCPP_DEBUG_LEVEL >= 2 private: - static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l); - void __link_nodes_at_front(__node_pointer __f, __node_pointer __l); - void __link_nodes_at_back (__node_pointer __f, __node_pointer __l); + static void __link_nodes (__link_pointer __p, __link_pointer __f, __link_pointer __l); + void __link_nodes_at_front(__link_pointer __f, __link_pointer __l); + void __link_nodes_at_back (__link_pointer __f, __link_pointer __l); iterator __iterator(size_type __n); template static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp); @@ -1049,7 +1073,7 @@ private: template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l) { __p->__prev_->__next_ = __f; __f->__prev_ = __p->__prev_; @@ -1061,9 +1085,9 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l) { - __f->__prev_ = base::__end_.__self(); + __f->__prev_ = base::__end_as_link(); __l->__next_ = base::__end_.__next_; __l->__next_->__prev_ = __l; base::__end_.__next_ = __f; @@ -1073,9 +1097,9 @@ list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l) template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l) { - __l->__next_ = base::__end_.__self(); + __l->__next_ = base::__end_as_link(); __f->__prev_ = base::__end_.__prev_; __f->__prev_->__next_ = __f; base::__end_.__prev_ = __l; @@ -1352,12 +1376,12 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link()); ++base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__hold.release()->__as_link(), this); #else - return iterator(__hold.release()); + return iterator(__hold.release()->__as_link()); #endif } @@ -1383,9 +1407,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - __r = iterator(__hold.get(), this); + __r = iterator(__hold->__as_link(), this); #else - __r = iterator(__hold.get()); + __r = iterator(__hold->__as_link()); #endif __hold.release(); iterator __e = __r; @@ -1397,7 +1421,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1408,8 +1432,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1451,9 +1475,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - __r = iterator(__hold.get(), this); + __r = iterator(__hold.get()->__as_link(), this); #else - __r = iterator(__hold.get()); + __r = iterator(__hold.get()->__as_link()); #endif __hold.release(); iterator __e = __r; @@ -1465,7 +1489,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1476,8 +1500,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1503,7 +1527,8 @@ list<_Tp, _Alloc>::push_front(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes_at_front(__nl, __nl); ++base::__sz(); __hold.release(); } @@ -1516,7 +1541,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1531,7 +1556,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1544,7 +1569,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1560,7 +1585,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1574,7 +1599,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes_at_back(__nl, __nl); ++base::__sz(); __hold.release(); } @@ -1594,12 +1620,14 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_pointer __nl = __hold.get()->__as_link(); + __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); + __hold.release(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__nl, this); #else - return iterator(__hold.release()); + return iterator(__nl); #endif } @@ -1619,12 +1647,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); + __hold.release(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__nl, this); #else - return iterator(__hold.release()); + return iterator(__nl); #endif } @@ -1636,7 +1666,7 @@ list<_Tp, _Alloc>::pop_front() { _LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = base::__end_.__next_; + __link_pointer __n = base::__end_.__next_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1654,8 +1684,9 @@ list<_Tp, _Alloc>::pop_front() } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } template @@ -1664,7 +1695,7 @@ list<_Tp, _Alloc>::pop_back() { _LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = base::__end_.__prev_; + __link_pointer __n = base::__end_.__prev_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1682,8 +1713,9 @@ list<_Tp, _Alloc>::pop_back() } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } template @@ -1698,8 +1730,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p) _LIBCPP_ASSERT(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = __p.__ptr_; - __node_pointer __r = __n->__next_; + __link_pointer __n = __p.__ptr_; + __link_pointer __r = __n->__next_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1717,8 +1749,9 @@ list<_Tp, _Alloc>::erase(const_iterator __p) } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__r, this); #else @@ -1741,7 +1774,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); while (__f != __l) { - __node_pointer __n = __f.__ptr_; + __link_pointer __n = __f.__ptr_; ++__f; --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1759,8 +1792,9 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } } #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1787,9 +1821,9 @@ list<_Tp, _Alloc>::resize(size_type __n) __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - iterator __r = iterator(__hold.release(), this); + iterator __r = iterator(__hold.release()->__as_link(), this); #else - iterator __r = iterator(__hold.release()); + iterator __r = iterator(__hold.release()->__as_link()); #endif iterator __e = __r; #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1800,7 +1834,7 @@ list<_Tp, _Alloc>::resize(size_type __n) { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1811,8 +1845,8 @@ list<_Tp, _Alloc>::resize(size_type __n) while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1845,10 +1879,11 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); ++__ds; + __link_pointer __nl = __hold.release()->__as_link(); #if _LIBCPP_DEBUG_LEVEL >= 2 - iterator __r = iterator(__hold.release(), this); + iterator __r = iterator(__nl, this); #else - iterator __r = iterator(__hold.release()); + iterator __r = iterator(__nl); #endif iterator __e = __r; #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1859,7 +1894,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1870,8 +1905,8 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1883,8 +1918,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) throw; } #endif // _LIBCPP_NO_EXCEPTIONS - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_); + __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_); base::__sz() += __ds; } } @@ -1902,8 +1936,8 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) #endif if (!__c.empty()) { - __node_pointer __f = __c.__end_.__next_; - __node_pointer __l = __c.__end_.__prev_; + __link_pointer __f = __c.__end_.__next_; + __link_pointer __l = __c.__end_.__prev_; base::__unlink_nodes(__f, __l); __link_nodes(__p.__ptr_, __f, __l); base::__sz() += __c.__sz(); @@ -1916,8 +1950,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { --__p; iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ != __c.__end_as_link()) { __cn1->__add(*__p); (*__p)->__c_ = __cn1; @@ -1947,7 +1980,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) #endif if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { - __node_pointer __f = __i.__ptr_; + __link_pointer __f = __i.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__p.__ptr_, __f, __f); --__c.__sz(); @@ -2001,9 +2034,9 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con __c.__sz() -= __s; base::__sz() += __s; } - __node_pointer __first = __f.__ptr_; + __link_pointer __first = __f.__ptr_; --__l; - __node_pointer __last = __l.__ptr_; + __link_pointer __last = __l.__ptr_; base::__unlink_nodes(__first, __last); __link_nodes(__p.__ptr_, __first, __last); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -2014,7 +2047,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con { --__p; iterator* __j = static_cast((*__p)->__i_); - for (__node_pointer __k = __f.__ptr_; + for (__link_pointer __k = __f.__ptr_; __k != __l.__ptr_; __k = __k->__next_) { if (__j->__ptr_ == __k) @@ -2126,8 +2159,8 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) ; base::__sz() += __ds; __c.__sz() -= __ds; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; __f2 = __m2; base::__unlink_nodes(__f, __l); __m2 = _VSTD::next(__f1); @@ -2146,8 +2179,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { --__p; iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ != __c.__end_as_link()) { __cn1->__add(*__p); (*__p)->__c_ = __cn1; @@ -2190,7 +2222,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ case 2: if (__comp(*--__e2, *__f1)) { - __node_pointer __f = __e2.__ptr_; + __link_pointer __f = __e2.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__f1.__ptr_, __f, __f); return __e2; @@ -2206,8 +2238,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = _VSTD::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; __r = __f2; __e1 = __f2 = __m2; base::__unlink_nodes(__f, __l); @@ -2224,8 +2256,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = _VSTD::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; if (__e1 == __f2) __e1 = __m2; __f2 = __m2; @@ -2269,8 +2301,7 @@ template bool list<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const { - return __i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(this->__end_))); + return __i->__ptr_ != this->__end_as_link(); } template diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale index e683ba33ae9d..84cb5a5ef6cd 100644 --- a/contrib/libc++/include/locale +++ b/contrib/libc++/include/locale @@ -1888,6 +1888,9 @@ protected: virtual const string_type& __r() const; virtual const string_type& __x() const; virtual const string_type& __X() const; + + _LIBCPP_ALWAYS_INLINE + ~__time_get_c_storage() {} }; template > @@ -3773,11 +3776,14 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: + _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_ALWAYS_INLINE wstring_convert(_Codecvt* __pcvt, state_type __state); _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_ALWAYS_INLINE wstring_convert(wstring_convert&& __wc); #endif ~wstring_convert(); @@ -3811,7 +3817,7 @@ public: }; template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt) : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) @@ -3819,7 +3825,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: } template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt, state_type __state) : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) @@ -3838,7 +3844,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(wstring_convert&& __wc) : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)), @@ -4313,18 +4319,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir int __width = __cv_->encoding(); if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync()) return pos_type(off_type(-1)); - // __width > 0 || __off == 0 - switch (__way) - { - case ios_base::beg: - break; - case ios_base::cur: - break; - case ios_base::end: - break; - default: + // __width > 0 || __off == 0, now check __way + if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end) return pos_type(off_type(-1)); - } pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om); __r.state(__st_); return __r; diff --git a/contrib/libc++/include/map b/contrib/libc++/include/map index eb6b8ed05308..87add437a545 100644 --- a/contrib/libc++/include/map +++ b/contrib/libc++/include/map @@ -126,9 +126,11 @@ public: template iterator emplace_hint(const_iterator position, Args&&... args); pair insert(const value_type& v); + pair insert( value_type&& v); // C++17 template pair insert(P&& p); iterator insert(const_iterator position, const value_type& v); + iterator insert(const_iterator position, value_type&& v); // C++17 template iterator insert(const_iterator position, P&& p); template @@ -336,9 +338,11 @@ public: template iterator emplace_hint(const_iterator position, Args&&... args); iterator insert(const value_type& v); + iterator insert( value_type&& v); // C++17 template iterator insert(P&& p); iterator insert(const_iterator position, const value_type& v); + iterator insert(const_iterator position, value_type&& v); // C++17 template iterator insert(const_iterator position, P&& p); template @@ -704,13 +708,8 @@ public: typedef pair<__key_type, __mapped_type> value_type; typedef typename _TreeIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __map_iterator() _NOEXCEPT {} @@ -770,13 +769,8 @@ public: typedef pair<__key_type, __mapped_type> value_type; typedef typename _TreeIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __map_const_iterator() _NOEXCEPT {} @@ -840,6 +834,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { @@ -1096,6 +1093,17 @@ public: insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_unique(__p.__i_, __v);} +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + _LIBCPP_INLINE_VISIBILITY + pair + insert( value_type&& __v) {return __tree_.__insert_unique(_VSTD::forward(__v));} + + _LIBCPP_INLINE_VISIBILITY + iterator + insert(const_iterator __p, value_type&& __v) + {return __tree_.__insert_unique(__p.__i_, _VSTD::forward(__v));} +#endif + template _LIBCPP_INLINE_VISIBILITY void insert(_InputIterator __f, _InputIterator __l) @@ -1523,7 +1531,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template @@ -1696,6 +1704,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { @@ -1944,6 +1955,15 @@ public: iterator insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_multi(__p.__i_, __v);} +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + _LIBCPP_INLINE_VISIBILITY + iterator insert( value_type&& __v) {return __tree_.__insert_multi(_VSTD::forward(__v));} + + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, value_type&& __v) + {return __tree_.__insert_multi(__p.__i_, _VSTD::forward(__v));} +#endif + template _LIBCPP_INLINE_VISIBILITY void insert(_InputIterator __f, _InputIterator __l) diff --git a/contrib/libc++/include/math.h b/contrib/libc++/include/math.h new file mode 100644 index 000000000000..20205544d51d --- /dev/null +++ b/contrib/libc++/include/math.h @@ -0,0 +1,1419 @@ +// -*- C++ -*- +//===---------------------------- math.h ----------------------------------===// +// +// 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_MATH_H +#define _LIBCPP_MATH_H + +/* + math.h synopsis + +Macros: + + HUGE_VAL + HUGE_VALF // C99 + HUGE_VALL // C99 + INFINITY // C99 + NAN // C99 + FP_INFINITE // C99 + FP_NAN // C99 + FP_NORMAL // C99 + FP_SUBNORMAL // C99 + FP_ZERO // C99 + FP_FAST_FMA // C99 + FP_FAST_FMAF // C99 + FP_FAST_FMAL // C99 + FP_ILOGB0 // C99 + FP_ILOGBNAN // C99 + MATH_ERRNO // C99 + MATH_ERREXCEPT // C99 + math_errhandling // C99 + +Types: + + float_t // C99 + double_t // C99 + +// C90 + +floating_point abs(floating_point x); + +floating_point acos (arithmetic x); +float acosf(float x); +long double acosl(long double x); + +floating_point asin (arithmetic x); +float asinf(float x); +long double asinl(long double x); + +floating_point atan (arithmetic x); +float atanf(float x); +long double atanl(long double x); + +floating_point atan2 (arithmetic y, arithmetic x); +float atan2f(float y, float x); +long double atan2l(long double y, long double x); + +floating_point ceil (arithmetic x); +float ceilf(float x); +long double ceill(long double x); + +floating_point cos (arithmetic x); +float cosf(float x); +long double cosl(long double x); + +floating_point cosh (arithmetic x); +float coshf(float x); +long double coshl(long double x); + +floating_point exp (arithmetic x); +float expf(float x); +long double expl(long double x); + +floating_point fabs (arithmetic x); +float fabsf(float x); +long double fabsl(long double x); + +floating_point floor (arithmetic x); +float floorf(float x); +long double floorl(long double x); + +floating_point fmod (arithmetic x, arithmetic y); +float fmodf(float x, float y); +long double fmodl(long double x, long double y); + +floating_point frexp (arithmetic value, int* exp); +float frexpf(float value, int* exp); +long double frexpl(long double value, int* exp); + +floating_point ldexp (arithmetic value, int exp); +float ldexpf(float value, int exp); +long double ldexpl(long double value, int exp); + +floating_point log (arithmetic x); +float logf(float x); +long double logl(long double x); + +floating_point log10 (arithmetic x); +float log10f(float x); +long double log10l(long double x); + +floating_point modf (floating_point value, floating_point* iptr); +float modff(float value, float* iptr); +long double modfl(long double value, long double* iptr); + +floating_point pow (arithmetic x, arithmetic y); +float powf(float x, float y); +long double powl(long double x, long double y); + +floating_point sin (arithmetic x); +float sinf(float x); +long double sinl(long double x); + +floating_point sinh (arithmetic x); +float sinhf(float x); +long double sinhl(long double x); + +floating_point sqrt (arithmetic x); +float sqrtf(float x); +long double sqrtl(long double x); + +floating_point tan (arithmetic x); +float tanf(float x); +long double tanl(long double x); + +floating_point tanh (arithmetic x); +float tanhf(float x); +long double tanhl(long double x); + +// C99 + +bool signbit(arithmetic x); + +int fpclassify(arithmetic x); + +bool isfinite(arithmetic x); +bool isinf(arithmetic x); +bool isnan(arithmetic x); +bool isnormal(arithmetic x); + +bool isgreater(arithmetic x, arithmetic y); +bool isgreaterequal(arithmetic x, arithmetic y); +bool isless(arithmetic x, arithmetic y); +bool islessequal(arithmetic x, arithmetic y); +bool islessgreater(arithmetic x, arithmetic y); +bool isunordered(arithmetic x, arithmetic y); + +floating_point acosh (arithmetic x); +float acoshf(float x); +long double acoshl(long double x); + +floating_point asinh (arithmetic x); +float asinhf(float x); +long double asinhl(long double x); + +floating_point atanh (arithmetic x); +float atanhf(float x); +long double atanhl(long double x); + +floating_point cbrt (arithmetic x); +float cbrtf(float x); +long double cbrtl(long double x); + +floating_point copysign (arithmetic x, arithmetic y); +float copysignf(float x, float y); +long double copysignl(long double x, long double y); + +floating_point erf (arithmetic x); +float erff(float x); +long double erfl(long double x); + +floating_point erfc (arithmetic x); +float erfcf(float x); +long double erfcl(long double x); + +floating_point exp2 (arithmetic x); +float exp2f(float x); +long double exp2l(long double x); + +floating_point expm1 (arithmetic x); +float expm1f(float x); +long double expm1l(long double x); + +floating_point fdim (arithmetic x, arithmetic y); +float fdimf(float x, float y); +long double fdiml(long double x, long double y); + +floating_point fma (arithmetic x, arithmetic y, arithmetic z); +float fmaf(float x, float y, float z); +long double fmal(long double x, long double y, long double z); + +floating_point fmax (arithmetic x, arithmetic y); +float fmaxf(float x, float y); +long double fmaxl(long double x, long double y); + +floating_point fmin (arithmetic x, arithmetic y); +float fminf(float x, float y); +long double fminl(long double x, long double y); + +floating_point hypot (arithmetic x, arithmetic y); +float hypotf(float x, float y); +long double hypotl(long double x, long double y); + +int ilogb (arithmetic x); +int ilogbf(float x); +int ilogbl(long double x); + +floating_point lgamma (arithmetic x); +float lgammaf(float x); +long double lgammal(long double x); + +long long llrint (arithmetic x); +long long llrintf(float x); +long long llrintl(long double x); + +long long llround (arithmetic x); +long long llroundf(float x); +long long llroundl(long double x); + +floating_point log1p (arithmetic x); +float log1pf(float x); +long double log1pl(long double x); + +floating_point log2 (arithmetic x); +float log2f(float x); +long double log2l(long double x); + +floating_point logb (arithmetic x); +float logbf(float x); +long double logbl(long double x); + +long lrint (arithmetic x); +long lrintf(float x); +long lrintl(long double x); + +long lround (arithmetic x); +long lroundf(float x); +long lroundl(long double x); + +double nan (const char* str); +float nanf(const char* str); +long double nanl(const char* str); + +floating_point nearbyint (arithmetic x); +float nearbyintf(float x); +long double nearbyintl(long double x); + +floating_point nextafter (arithmetic x, arithmetic y); +float nextafterf(float x, float y); +long double nextafterl(long double x, long double y); + +floating_point nexttoward (arithmetic x, long double y); +float nexttowardf(float x, long double y); +long double nexttowardl(long double x, long double y); + +floating_point remainder (arithmetic x, arithmetic y); +float remainderf(float x, float y); +long double remainderl(long double x, long double y); + +floating_point remquo (arithmetic x, arithmetic y, int* pquo); +float remquof(float x, float y, int* pquo); +long double remquol(long double x, long double y, int* pquo); + +floating_point rint (arithmetic x); +float rintf(float x); +long double rintl(long double x); + +floating_point round (arithmetic x); +float roundf(float x); +long double roundl(long double x); + +floating_point scalbln (arithmetic x, long ex); +float scalblnf(float x, long ex); +long double scalblnl(long double x, long ex); + +floating_point scalbn (arithmetic x, int ex); +float scalbnf(float x, int ex); +long double scalbnl(long double x, int ex); + +floating_point tgamma (arithmetic x); +float tgammaf(float x); +long double tgammal(long double x); + +floating_point trunc (arithmetic x); +float truncf(float x); +long double truncl(long double x); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { + +#include + +#ifdef _LIBCPP_MSVCRT +#include "support/win32/math_win32.h" +#endif + +// signbit + +#ifdef signbit + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT +{ + return signbit(__lcpp_x); +} + +#undef signbit + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +signbit(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // signbit + +// fpclassify + +#ifdef fpclassify + +template +_LIBCPP_ALWAYS_INLINE +int +__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT +{ + return fpclassify(__lcpp_x); +} + +#undef fpclassify + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, int>::type +fpclassify(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // fpclassify + +// isfinite + +#ifdef isfinite + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT +{ + return isfinite(__lcpp_x); +} + +#undef isfinite + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isfinite(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isfinite + +// isinf + +#ifdef isinf + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT +{ + return isinf(__lcpp_x); +} + +#undef isinf + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isinf(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isinf + +// isnan + +#ifdef isnan + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT +{ + return isnan(__lcpp_x); +} + +#undef isnan + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isnan(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isnan + +// isnormal + +#ifdef isnormal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT +{ + return isnormal(__lcpp_x); +} + +#undef isnormal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isnormal(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isnormal + +// isgreater + +#ifdef isgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isgreater(__lcpp_x, __lcpp_y); +} + +#undef isgreater + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isgreater + +// isgreaterequal + +#ifdef isgreaterequal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isgreaterequal(__lcpp_x, __lcpp_y); +} + +#undef isgreaterequal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isgreaterequal + +// isless + +#ifdef isless + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isless(__lcpp_x, __lcpp_y); +} + +#undef isless + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isless + +// islessequal + +#ifdef islessequal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return islessequal(__lcpp_x, __lcpp_y); +} + +#undef islessequal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // islessequal + +// islessgreater + +#ifdef islessgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return islessgreater(__lcpp_x, __lcpp_y); +} + +#undef islessgreater + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // islessgreater + +// isunordered + +#ifdef isunordered + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isunordered(__lcpp_x, __lcpp_y); +} + +#undef isunordered + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isunordered + +#ifndef __sun__ + +// abs + +#if !defined(_AIX) +inline _LIBCPP_INLINE_VISIBILITY +float +abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} + +inline _LIBCPP_INLINE_VISIBILITY +double +abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);} + +inline _LIBCPP_INLINE_VISIBILITY +long double +abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} +#endif // !defined(_AIX) + +// acos + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);} + +// asin + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);} + +// atan + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);} + +// atan2 + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); +} + +// ceil + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);} + +// cos + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);} + +// cosh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);} + +// exp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);} + +// fabs + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);} + +// floor + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);} + +// fmod + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// frexp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);} + +// ldexp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);} + +// log + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);} + +// log10 + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);} + +// modf + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} +#endif + +// pow + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// sin + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);} + +// sinh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);} + +// sqrt + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} +#endif + +#endif // __sun__ +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} +#ifndef __sun__ + +// tan + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);} + +// tanh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);} + +// acosh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);} +#endif + +// asinh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);} +#endif + +// atanh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);} +#endif + +// cbrt + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} +#endif + +// copysign + +#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12) +inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, + float __lcpp_y) _NOEXCEPT { + return copysignf(__lcpp_x, __lcpp_y); +} +inline _LIBCPP_INLINE_VISIBILITY long double +copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { + return copysignl(__lcpp_x, __lcpp_y); +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +#ifndef _LIBCPP_MSVCRT + +// erf + +inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);} + +// erfc + +inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);} + +// exp2 + +inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);} + +// expm1 + +inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);} + +// fdim + +inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// fma + +inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value && + std::is_arithmetic<_A3>::value, + std::__promote<_A1, _A2, _A3> +>::type +fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value && + std::is_same<_A3, __result_type>::value)), ""); + return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); +} + +// fmax + +inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// fmin + +inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// hypot + +inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// ilogb + +inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, int>::type +ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);} + +// lgamma + +inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);} + +// llrint + +inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long long>::type +llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);} + +// llround + +inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long long>::type +llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);} + +// log1p + +inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);} + +// log2 + +inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);} + +// logb + +inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);} + +// lrint + +inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long>::type +lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);} + +// lround + +inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long>::type +lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);} + +// nan + +// nearbyint + +inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);} + +// nextafter + +inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// nexttoward + +inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);} + +// remainder + +inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// remquo + +inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); +} + +// rint + +inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);} + +// round + +inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);} + +// scalbln + +inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);} + +// scalbn + +inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);} + +// tgamma + +inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);} + +// trunc + +inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} + +#endif // !_LIBCPP_MSVCRT +#endif // __sun__ + +} // extern "C++" + +#endif // __cplusplus + +#endif // _LIBCPP_MATH_H diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index df35a07143ce..3ef687c1774b 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -612,7 +612,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include #endif -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include #endif @@ -932,6 +932,15 @@ public: {return _VSTD::addressof(__r);} }; +template +struct __rebind_pointer { +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + typedef typename pointer_traits<_From>::template rebind<_To> type; +#else + typedef typename pointer_traits<_From>::template rebind<_To>::other type; +#endif +}; + // allocator_traits namespace __has_pointer_type_imp @@ -1669,7 +1678,7 @@ private: {return __a.max_size();} _LIBCPP_INLINE_VISIBILITY static size_type __max_size(false_type, const allocator_type&) - {return numeric_limits::max();} + {return numeric_limits::max() / sizeof(value_type);} _LIBCPP_INLINE_VISIBILITY static allocator_type @@ -1900,6 +1909,10 @@ public: _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) {::new(&*__x_) _Tp(__element); return *this;} +#if _LIBCPP_STD_VER >= 14 + _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element) + {::new(&*__x_) _Tp(_VSTD::move(__element)); return *this;} +#endif _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) {raw_storage_iterator __t(*this); ++__x_; return __t;} @@ -2659,10 +2672,17 @@ public: : __ptr_(__u->release(), _VSTD::forward(__u->get_deleter())) {} template - _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) + _LIBCPP_INLINE_VISIBILITY + typename enable_if< + !is_array<_Up>::value && + is_convertible::pointer, pointer>::value && + is_assignable::value, + unique_ptr& + >::type + operator=(unique_ptr<_Up, _Ep> __u) { reset(__u.release()); - __ptr_.second() = _VSTD::forward(__u.get_deleter()); + __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); return *this; } @@ -3174,7 +3194,7 @@ struct __murmur2_or_cityhash<_Size, 32> // murmur2 template _Size -__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const _Size __m = 0x5bd1e995; const _Size __r = 24; @@ -3324,7 +3344,7 @@ struct __murmur2_or_cityhash<_Size, 64> // cityhash64 template _Size -__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const char* __s = static_cast(__key); if (__len <= 32) { @@ -3854,7 +3874,9 @@ private: struct __nat {int __for_bool_;}; public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; template explicit shared_ptr(_Yp* __p, @@ -3867,15 +3889,18 @@ public: typename enable_if::value, __nat>::type = __nat()); template shared_ptr(nullptr_t __p, _Dp __d); template shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); - template shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; + template _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr& __r) _NOEXCEPT; template + _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, typename enable_if::value, __nat>::type = __nat()) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr&& __r) _NOEXCEPT; - template shared_ptr(shared_ptr<_Yp>&& __r, + template _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, typename enable_if::value, __nat>::type = __nat()) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -3932,6 +3957,7 @@ public: ~shared_ptr(); + _LIBCPP_INLINE_VISIBILITY shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; template typename enable_if @@ -3939,8 +3965,10 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; template typename enable_if @@ -3948,6 +3976,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr<_Tp>& >::type + _LIBCPP_INLINE_VISIBILITY operator=(shared_ptr<_Yp>&& __r); template typename enable_if @@ -3956,6 +3985,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr >::type& + _LIBCPP_INLINE_VISIBILITY operator=(auto_ptr<_Yp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template @@ -3965,6 +3995,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(auto_ptr<_Yp> __r); #endif template @@ -3975,12 +4006,16 @@ public: shared_ptr& >::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY operator=(unique_ptr<_Yp, _Dp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY operator=(unique_ptr<_Yp, _Dp> __r); #endif + _LIBCPP_INLINE_VISIBILITY void swap(shared_ptr& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT; template typename enable_if @@ -3988,6 +4023,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p); template typename enable_if @@ -3995,6 +4031,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p, _Dp __d); template typename enable_if @@ -4002,6 +4039,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p, _Dp __d, _Alloc __a); _LIBCPP_INLINE_VISIBILITY @@ -4103,7 +4141,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr() _NOEXCEPT : __ptr_(0), @@ -4112,7 +4150,7 @@ shared_ptr<_Tp>::shared_ptr() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(0), @@ -4235,7 +4273,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT : __ptr_(__p), __cntrl_(__r.__cntrl_) @@ -4245,7 +4283,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEX } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4256,7 +4294,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, typename enable_if::value, __nat>::type) _NOEXCEPT @@ -4270,7 +4308,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4281,7 +4319,7 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, typename enable_if::value, __nat>::type) _NOEXCEPT @@ -4568,7 +4606,7 @@ shared_ptr<_Tp>::~shared_ptr() } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>& shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT { @@ -4578,7 +4616,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4593,7 +4631,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>& shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT { @@ -4603,7 +4641,7 @@ shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4617,7 +4655,7 @@ shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < !is_array<_Yp>::value && @@ -4632,7 +4670,7 @@ shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < !is_array<_Yp>::value && @@ -4680,7 +4718,7 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT { @@ -4689,7 +4727,7 @@ shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void shared_ptr<_Tp>::reset() _NOEXCEPT { @@ -4698,7 +4736,7 @@ shared_ptr<_Tp>::reset() _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4711,7 +4749,7 @@ shared_ptr<_Tp>::reset(_Yp* __p) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4724,7 +4762,7 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5041,23 +5079,27 @@ private: __shared_weak_count* __cntrl_; public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; - template weak_ptr(shared_ptr<_Yp> const& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr const& __r) _NOEXCEPT; - template weak_ptr(weak_ptr<_Yp> const& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr&& __r) _NOEXCEPT; - template weak_ptr(weak_ptr<_Yp>&& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~weak_ptr(); + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; template typename enable_if @@ -5065,10 +5107,12 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; template typename enable_if @@ -5076,6 +5120,7 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -5086,9 +5131,12 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void swap(weak_ptr& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -5112,7 +5160,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR weak_ptr<_Tp>::weak_ptr() _NOEXCEPT : __ptr_(0), @@ -5121,7 +5169,7 @@ weak_ptr<_Tp>::weak_ptr() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -5132,7 +5180,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5145,7 +5193,7 @@ weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5159,7 +5207,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -5170,7 +5218,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5191,7 +5239,7 @@ weak_ptr<_Tp>::~weak_ptr() } template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT { @@ -5201,7 +5249,7 @@ weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5216,7 +5264,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT { @@ -5226,7 +5274,7 @@ weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5242,7 +5290,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5255,7 +5303,7 @@ weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT { @@ -5272,7 +5320,7 @@ swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void weak_ptr<_Tp>::reset() _NOEXCEPT { @@ -5305,7 +5353,11 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT return __r; } +#if _LIBCPP_STD_VER > 14 +template struct owner_less; +#else template struct owner_less; +#endif template struct _LIBCPP_TYPE_VIS_ONLY owner_less > @@ -5339,6 +5391,30 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less > {return __x.owner_before(__y);} }; +#if _LIBCPP_STD_VER > 14 +template <> +struct _LIBCPP_TYPE_VIS_ONLY owner_less +{ + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + typedef void is_transparent; +}; +#endif + template class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this { @@ -5381,7 +5457,9 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only +// enabled with clang. +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) class _LIBCPP_TYPE_VIS __sp_mut { @@ -5507,7 +5585,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v return atomic_compare_exchange_weak(__p, __v, __w); } -#endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) //enum class struct _LIBCPP_TYPE_VIS pointer_safety @@ -5574,6 +5652,15 @@ template _LIBCPP_INLINE_VISIBILITY void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} +template > +struct __noexcept_move_assign_container : public integral_constant 14 + || _Traits::is_always_equal::value +#else + && is_nothrow_move_assignable<_Alloc>::value +#endif + > {}; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/module.modulemap b/contrib/libc++/include/module.modulemap index 3c0700eca443..3fb7428411df 100644 --- a/contrib/libc++/include/module.modulemap +++ b/contrib/libc++/include/module.modulemap @@ -455,9 +455,13 @@ module std [system] { export * } + // FIXME: We don't have modules for the headers, because they might + // be included from the C library's headers, and that would create a #include + // cycle. For the same reason, we don't have a module for __config. + //module __config { header "__config" export * } + // FIXME: These should be private. module __bit_reference { header "__bit_reference" export * } - module __config { header "__config" export * } module __debug { header "__debug" export * } module __functional_base { header "__functional_base" export * } module __hash_table { header "__hash_table" export * } diff --git a/contrib/libc++/include/mutex b/contrib/libc++/include/mutex index 373d75b09789..a0875a568ec6 100644 --- a/contrib/libc++/include/mutex +++ b/contrib/libc++/include/mutex @@ -179,7 +179,9 @@ template #ifndef _LIBCPP_HAS_NO_VARIADICS #include #endif +#ifndef _LIBCPP_HAS_NO_THREADS #include +#endif #include <__undef_min_max> diff --git a/contrib/libc++/include/random b/contrib/libc++/include/random index 64382a3d9aa6..794bf7b3fd15 100644 --- a/contrib/libc++/include/random +++ b/contrib/libc++/include/random @@ -3119,6 +3119,7 @@ public: independent_bits_engine<_Eng, _Wp, _UI>& __x); private: + _LIBCPP_INLINE_VISIBILITY result_type __eval(false_type); result_type __eval(true_type); @@ -3144,7 +3145,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) { @@ -3735,7 +3736,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -3765,7 +3766,7 @@ public: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename uniform_real_distribution<_RealType>::result_type uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { @@ -3851,7 +3852,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -3878,7 +3879,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline bernoulli_distribution::result_type bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) { @@ -5522,7 +5523,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -5552,7 +5553,7 @@ public: template template -inline _LIBCPP_INLINE_VISIBILITY +inline _RealType cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { @@ -6044,9 +6045,6 @@ basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discrete_distribution<_IT>& __x) { - typedef discrete_distribution<_IT> _Eng; - typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; @@ -6358,7 +6356,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, { typedef piecewise_constant_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; @@ -6698,7 +6695,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, { typedef piecewise_linear_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; diff --git a/contrib/libc++/include/ratio b/contrib/libc++/include/ratio index f623a062f2ce..8f708ce478d3 100644 --- a/contrib/libc++/include/ratio +++ b/contrib/libc++/include/ratio @@ -62,6 +62,19 @@ typedef ratio< 1000000000000000000, 1> exa; typedef ratio< 1000000000000000000000, 1> zetta; // not supported typedef ratio<1000000000000000000000000, 1> yotta; // not supported + // 20.11.5, ratio comparison + template constexpr bool ratio_equal_v + = ratio_equal::value; // C++17 + template constexpr bool ratio_not_equal_v + = ratio_not_equal::value; // C++17 + template constexpr bool ratio_less_v + = ratio_less::value; // C++17 + template constexpr bool ratio_less_equal_v + = ratio_less_equal::value; // C++17 + template constexpr bool ratio_greater_v + = ratio_greater::value; // C++17 + template constexpr bool ratio_greater_equal_v + = ratio_greater_equal::value; // C++17 } */ @@ -485,6 +498,26 @@ struct __ratio_gcd __static_lcm<_R1::den, _R2::den>::value> type; }; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool ratio_equal_v + = ratio_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_not_equal_v + = ratio_not_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_v + = ratio_less<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_equal_v + = ratio_less_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_v + = ratio_greater<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_equal_v + = ratio_greater_equal<_R1, _R2>::value; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_RATIO diff --git a/contrib/libc++/include/regex b/contrib/libc++/include/regex index bd48fb8da04b..1139d8fb2a90 100644 --- a/contrib/libc++/include/regex +++ b/contrib/libc++/include/regex @@ -762,6 +762,7 @@ typedef regex_token_iterator wsregex_token_iterator; #include #include #include +#include #include <__undef_min_max> @@ -955,6 +956,17 @@ public: regex_constants::error_type code() const {return __code_;} }; +template +_LIBCPP_ALWAYS_INLINE +void __throw_regex_error() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw regex_error(_Ev); +#else + assert(!"regex_error"); +#endif +} + template struct _LIBCPP_TYPE_VIS_ONLY regex_traits { @@ -964,7 +976,12 @@ public: typedef locale locale_type; typedef ctype_base::mask char_class_type; +#if defined(__mips__) && defined(__GLIBC__) + static const char_class_type __regex_word = static_cast(_ISbit(15)); +#else static const char_class_type __regex_word = 0x80; +#endif + private: locale __loc_; const ctype* __ct_; @@ -1036,6 +1053,7 @@ private: _LIBCPP_INLINE_VISIBILITY int __regex_traits_value(char __ch, int __radix) const {return __regex_traits_value(static_cast(__ch), __radix);} + _LIBCPP_INLINE_VISIBILITY int __regex_traits_value(wchar_t __ch, int __radix) const; }; @@ -1258,7 +1276,7 @@ regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) } template -inline _LIBCPP_INLINE_VISIBILITY +inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { @@ -1721,6 +1739,8 @@ template void __back_ref<_CharT>::__exec(__state& __s) const { + if (__mexp_ > __s.__sub_matches_.size()) + __throw_regex_error(); sub_match& __sm = __s.__sub_matches_[__mexp_-1]; if (__sm.matched) { @@ -2256,10 +2276,8 @@ public: } else { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__b.size() != 1 || __e.size() != 1) - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__icase_) { __b[0] = __traits_.translate_nocase(__b[0]); @@ -2952,7 +2970,7 @@ public: _LIBCPP_INLINE_VISIBILITY __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) - : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {} + : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} virtual void __exec(__state&) const; }; @@ -3012,10 +3030,8 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, case egrep: __first = __parse_egrep(__first, __last); break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::__re_err_grammar); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } return __first; } @@ -3046,10 +3062,8 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, } } } -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first != __last) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } return __first; } @@ -3062,19 +3076,15 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, { __owns_one_state<_CharT>* __sa = __end_; _ForwardIterator __temp = __parse_ERE_branch(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; while (__first != __last && *__first == '|') { __owns_one_state<_CharT>* __sb = __end_; __temp = __parse_ERE_branch(++__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_alternation(__sa, __sb); __first = __temp; } @@ -3088,10 +3098,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) { _ForwardIterator __temp = __parse_ERE_expression(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); do { __first = __temp; @@ -3126,10 +3134,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, unsigned __temp_count = __marked_count_; ++__open_count_; __temp = __parse_extended_reg_exp(++__temp, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); --__open_count_; ++__temp; @@ -3194,10 +3200,8 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, unsigned __temp_count = __marked_count_; __first = __parse_RE_expression(__temp, __last); __temp = __parse_Back_close_paren(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); __first = __temp; } @@ -3511,22 +3515,16 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, int __min = 0; __first = __temp; __temp = __parse_DUP_COUNT(__first, __last, __min); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first != ',') { __temp = __parse_Back_close_brace(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true); __first = __temp; @@ -3537,18 +3535,14 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, int __max = -1; __first = __parse_DUP_COUNT(__first, __last, __max); __temp = __parse_Back_close_brace(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__max == -1) __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); else { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__max < __min) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true); } @@ -3608,15 +3602,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, { int __min; _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case '}': @@ -3631,10 +3621,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, break; case ',': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first == '}') { ++__first; @@ -3650,20 +3638,14 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, { int __max = -1; __temp = __parse_DUP_COUNT(__first, __last, __max); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != '}') - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__max < __min) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__grammar == ECMAScript && __first != __last && *__first == '?') { ++__first; @@ -3673,10 +3655,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, __push_loop(__min, __max, __s, __mexp_begin, __mexp_end); } break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } } break; @@ -3694,10 +3674,8 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs if (__first != __last && *__first == '[') { ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); bool __negate = false; if (*__first == '^') { @@ -3706,29 +3684,23 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs } __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); // __ml owned by *this -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') { __ml->__add_char(']'); ++__first; } __first = __parse_follow_list(__first, __last, __ml); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first == '-') { __ml->__add_char('-'); ++__first; } -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ']') - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); ++__first; } return __first; @@ -3848,10 +3820,8 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first, basic_string<_CharT>& __str, __bracket_expression<_CharT, _Traits>* __ml) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case 0: @@ -3892,10 +3862,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case '\\': @@ -3963,10 +3931,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, else __push_char(_CharT(__val)); } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); return __first; } @@ -3982,18 +3948,14 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first value_type _Equal_close[2] = {'=', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close, _Equal_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [= ... =] typedef typename _Traits::string_type string_type; string_type __collate_name = __traits_.lookup_collatename(__first, __temp); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__collate_name.empty()) - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end()); @@ -4009,10 +3971,8 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first case 2: __ml->__add_digraph(__collate_name[0], __collate_name[1]); break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } } __first = _VSTD::next(__temp, 2); @@ -4031,18 +3991,14 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first, value_type _Colon_close[2] = {':', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close, _Colon_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [: ... :] typedef typename _Traits::char_class_type char_class_type; char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__class_type == 0) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __ml->__add_class(__class_type); __first = _VSTD::next(__temp, 2); return __first; @@ -4060,22 +4016,17 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first, value_type _Dot_close[2] = {'.', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close, _Dot_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [. ... .] - typedef typename _Traits::string_type string_type; __col_sym = __traits_.lookup_collatename(__first, __temp); switch (__col_sym.size()) { case 1: case 2: break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } __first = _VSTD::next(__temp, 2); return __first; @@ -4219,10 +4170,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, 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); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = ++__temp; } break; @@ -4234,10 +4183,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, 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); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = ++__temp; } break; @@ -4274,19 +4221,15 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, case '(': { ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); _ForwardIterator __temp = _VSTD::next(__first); if (__temp != __last && *__first == '?' && *__temp == ':') { ++__open_count_; __first = __parse_ecma_exp(++__temp, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); --__open_count_; ++__first; } @@ -4296,16 +4239,20 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, unsigned __temp_count = __marked_count_; ++__open_count_; __first = __parse_ecma_exp(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); --__open_count_; ++__first; } } break; + case '*': + case '+': + case '?': + case '{': + __throw_regex_error(); + break; default: __first = __parse_pattern_character(__first, __last); break; @@ -4323,6 +4270,9 @@ basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first, if (__first != __last && *__first == '\\') { _ForwardIterator __t1 = _VSTD::next(__first); + if (__t1 == __last) + __throw_regex_error(); + _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); if (__t2 != __t1) __first = __t2; @@ -4360,10 +4310,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, unsigned __v = *__first - '0'; for (++__first; '0' <= *__first && *__first <= '9'; ++__first) __v = 10 * __v + *__first - '0'; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__v > mark_count()) - throw regex_error(regex_constants::error_backref); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_back_ref(__v); } } @@ -4479,62 +4427,42 @@ 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 + __throw_regex_error(); } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); break; case 'u': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); // drop through case 'x': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); if (__str) *__str = _CharT(__sum); @@ -4558,10 +4486,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(*__first); ++__first; } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); break; } } @@ -5422,8 +5348,8 @@ match_results<_BidirectionalIterator, _Allocator>::match_results( __unmatched_(), __prefix_(), __suffix_(), - __position_start_(), - __ready_(false) + __ready_(false), + __position_start_() { } @@ -5466,8 +5392,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, if ('0' <= *__fmt_first && *__fmt_first <= '9') { size_t __i = *__fmt_first - '0'; - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { @@ -5518,8 +5444,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, ++__fmt_first; __i = 10 * __i + *__fmt_first - '0'; } - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { @@ -5648,9 +5574,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } @@ -5720,9 +5644,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } } while (!__states.empty()); @@ -5808,9 +5730,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } } while (!__states.empty()); diff --git a/contrib/libc++/include/scoped_allocator b/contrib/libc++/include/scoped_allocator index cd4987ad9bb6..9436dac9c199 100644 --- a/contrib/libc++/include/scoped_allocator +++ b/contrib/libc++/include/scoped_allocator @@ -58,6 +58,8 @@ public: template scoped_allocator_adaptor(const scoped_allocator_adaptor&& other) noexcept; + scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; + scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; ~scoped_allocator_adaptor(); inner_allocator_type& inner_allocator() noexcept; @@ -457,6 +459,8 @@ public: scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT : base(_VSTD::move(__other)) {} + // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; + // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; // ~scoped_allocator_adaptor() = default; _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libc++/include/set b/contrib/libc++/include/set index 9d64a521da11..ac69e085241f 100644 --- a/contrib/libc++/include/set +++ b/contrib/libc++/include/set @@ -409,6 +409,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; @@ -819,6 +822,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; diff --git a/contrib/libc++/include/setjmp.h b/contrib/libc++/include/setjmp.h new file mode 100644 index 000000000000..464b4a540897 --- /dev/null +++ b/contrib/libc++/include/setjmp.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===--------------------------- setjmp.h ---------------------------------===// +// +// 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_SETJMP_H +#define _LIBCPP_SETJMP_H + +/* + setjmp.h synopsis + +Macros: + + setjmp + +Types: + + jmp_buf + +void longjmp(jmp_buf env, int val); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#ifndef setjmp +#define setjmp(env) setjmp(env) +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_SETJMP_H diff --git a/contrib/libc++/include/stddef.h b/contrib/libc++/include/stddef.h new file mode 100644 index 000000000000..8841bbea2978 --- /dev/null +++ b/contrib/libc++/include/stddef.h @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===--------------------------- stddef.h ---------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \ + defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDDEF_H) +#define _LIBCPP_STDDEF_H + +/* + stddef.h synopsis + +Macros: + + offsetof(type,member-designator) + NULL + +Types: + + ptrdiff_t + size_t + max_align_t + nullptr_t + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +extern "C++" { +#include <__nullptr> +using std::nullptr_t; +} + +// Re-use the compiler's max_align_t where possible. +#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) +typedef long double max_align_t; +#endif + +#endif + +#endif // _LIBCPP_STDDEF_H diff --git a/contrib/libc++/include/stdio.h b/contrib/libc++/include/stdio.h new file mode 100644 index 000000000000..56fb2d83bb28 --- /dev/null +++ b/contrib/libc++/include/stdio.h @@ -0,0 +1,127 @@ +// -*- C++ -*- +//===---------------------------- stdio.h ---------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_FILE) || defined(__need___FILE) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDIO_H) +#define _LIBCPP_STDIO_H + +/* + stdio.h synopsis + +Macros: + + BUFSIZ + EOF + FILENAME_MAX + FOPEN_MAX + L_tmpnam + NULL + SEEK_CUR + SEEK_END + SEEK_SET + TMP_MAX + _IOFBF + _IOLBF + _IONBF + stderr + stdin + stdout + +Types: + +FILE +fpos_t +size_t + +int remove(const char* filename); +int rename(const char* old, const char* new); +FILE* tmpfile(void); +char* tmpnam(char* s); +int fclose(FILE* stream); +int fflush(FILE* stream); +FILE* fopen(const char* restrict filename, const char* restrict mode); +FILE* freopen(const char* restrict filename, const char * restrict mode, + FILE * restrict stream); +void setbuf(FILE* restrict stream, char* restrict buf); +int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size); +int fprintf(FILE* restrict stream, const char* restrict format, ...); +int fscanf(FILE* restrict stream, const char * restrict format, ...); +int printf(const char* restrict format, ...); +int scanf(const char* restrict format, ...); +int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99 +int sprintf(char* restrict s, const char* restrict format, ...); +int sscanf(const char* restrict s, const char* restrict format, ...); +int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg); +int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99 +int vprintf(const char* restrict format, va_list arg); +int vscanf(const char* restrict format, va_list arg); // C99 +int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99 + va_list arg); +int vsprintf(char* restrict s, const char* restrict format, va_list arg); +int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99 +int fgetc(FILE* stream); +char* fgets(char* restrict s, int n, FILE* restrict stream); +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); // removed in C++14 +int putc(int c, FILE* stream); +int putchar(int c); +int puts(const char* s); +int ungetc(int c, FILE* stream); +size_t fread(void* restrict ptr, size_t size, size_t nmemb, + FILE* restrict stream); +size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, + FILE* restrict stream); +int fgetpos(FILE* restrict stream, fpos_t* restrict pos); +int fseek(FILE* stream, long offset, int whence); +int fsetpos(FILE*stream, const fpos_t* pos); +long ftell(FILE* stream); +void rewind(FILE* stream); +void clearerr(FILE* stream); +int feof(FILE* stream); +int ferror(FILE* stream); +void perror(const char* s); +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +// snprintf +#if defined(_LIBCPP_MSVCRT) +extern "C++" { +#include "support/win32/support.h" +} +#endif + +#undef getc +#undef putc +#undef clearerr +#undef feof +#undef ferror + +#endif + +#endif // _LIBCPP_STDIO_H diff --git a/contrib/libc++/include/stdlib.h b/contrib/libc++/include/stdlib.h new file mode 100644 index 000000000000..12fd676a15f5 --- /dev/null +++ b/contrib/libc++/include/stdlib.h @@ -0,0 +1,130 @@ +// -*- C++ -*- +//===--------------------------- stdlib.h ---------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_malloc_and_calloc) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDLIB_H) +#define _LIBCPP_STDLIB_H + +/* + stdlib.h synopsis + +Macros: + + EXIT_FAILURE + EXIT_SUCCESS + MB_CUR_MAX + NULL + RAND_MAX + +Types: + + size_t + div_t + ldiv_t + lldiv_t // C99 + +double atof (const char* nptr); +int atoi (const char* nptr); +long atol (const char* nptr); +long long atoll(const char* nptr); // C99 +double strtod (const char* restrict nptr, char** restrict endptr); +float strtof (const char* restrict nptr, char** restrict endptr); // C99 +long double strtold (const char* restrict nptr, char** restrict endptr); // C99 +long strtol (const char* restrict nptr, char** restrict endptr, int base); +long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 +unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); +unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 +int rand(void); +void srand(unsigned int seed); +void* calloc(size_t nmemb, size_t size); +void free(void* ptr); +void* malloc(size_t size); +void* realloc(void* ptr, size_t size); +void abort(void); +int atexit(void (*func)(void)); +void exit(int status); +void _Exit(int status); +char* getenv(const char* name); +int system(const char* string); +void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); +void qsort(void* base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); +int abs( int j); +long abs( long j); +long long abs(long long j); // C++0X +long labs( long j); +long long llabs(long long j); // C99 +div_t div( int numer, int denom); +ldiv_t div( long numer, long denom); +lldiv_t div(long long numer, long long denom); // C++0X +ldiv_t ldiv( long numer, long denom); +lldiv_t lldiv(long long numer, long long denom); // C99 +int mblen(const char* s, size_t n); +int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); +int wctomb(char* s, wchar_t wchar); +size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); +size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); +int at_quick_exit(void (*func)(void)) // C++11 +void quick_exit(int status); // C++11 +void *aligned_alloc(size_t alignment, size_t size); // C11 + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +extern "C++" { + +#ifdef _LIBCPP_MSVCRT +#include "support/win32/locale_win32.h" +#endif // _LIBCPP_MSVCRT + +#undef abs +#undef div +#undef labs +#undef ldiv +#ifndef _LIBCPP_HAS_NO_LONG_LONG +#undef llabs +#undef lldiv +#endif + +// MSVCRT already has the correct prototype in if __cplusplus is defined +#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);} +#endif // _LIBCPP_HAS_NO_LONG_LONG + +inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);} +#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 // _LIBCPP_MSVCRT / __sun__ / _AIX + +} // extern "C++" + +#endif // __cplusplus + +#endif // _LIBCPP_STDLIB_H diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index 6e63ab18418f..91502441e0c0 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -115,8 +115,8 @@ public: basic_string& operator=(const basic_string& str); basic_string& operator=(basic_string&& str) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value ); // C++17 basic_string& operator=(const value_type* s); basic_string& operator=(value_type c); basic_string& operator=(initializer_list); @@ -517,10 +517,14 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -550,7 +554,7 @@ char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_ } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits<_CharT>::length(const char_type* __s) { @@ -561,7 +565,7 @@ char_traits<_CharT>::length(const char_type* __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline const _CharT* char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -595,7 +599,7 @@ char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -607,7 +611,7 @@ char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _CharT* char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) { @@ -726,11 +730,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} + _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); + _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -742,10 +752,10 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xDFFF);} + {return int_type(0xFFFF);} }; -inline _LIBCPP_INLINE_VISIBILITY +inline int char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) { @@ -759,7 +769,7 @@ char_traits::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits::length(const char_type* __s) { @@ -769,7 +779,7 @@ char_traits::length(const char_type* __s) return __len; } -inline _LIBCPP_INLINE_VISIBILITY +inline const char16_t* char_traits::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -782,7 +792,7 @@ char_traits::find(const char_type* __s, size_t __n, const char_type& _ return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) { @@ -802,7 +812,7 @@ char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -813,7 +823,7 @@ char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::assign(char_type* __s, size_t __n, char_type __a) { @@ -839,11 +849,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} + _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); + _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -858,7 +874,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return int_type(0xFFFFFFFF);} }; -inline _LIBCPP_INLINE_VISIBILITY +inline int char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) { @@ -872,7 +888,7 @@ char_traits::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits::length(const char_type* __s) { @@ -882,7 +898,7 @@ char_traits::length(const char_type* __s) return __len; } -inline _LIBCPP_INLINE_VISIBILITY +inline const char32_t* char_traits::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -895,7 +911,7 @@ char_traits::find(const char_type* __s, size_t __n, const char_type& _ return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) { @@ -915,7 +931,7 @@ char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -926,7 +942,7 @@ char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::assign(char_type* __s, size_t __n, char_type __a) { @@ -1185,7 +1201,31 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common) #pragma warning( pop ) #endif // _LIBCPP_MSVC -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_NO_EXCEPTIONS +template +struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {}; +#elif defined(_LIBCPP_HAS_NO_NOEXCEPT) +template +struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {}; +#else +template ::value> +struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( + noexcept(++(declval<_Iter&>())) && + is_nothrow_assignable<_Iter&, _Iter>::value && + noexcept(declval<_Iter>() == declval<_Iter>()) && + noexcept(*declval<_Iter>()) +)) {}; + +template +struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {}; +#endif + + +template +struct __libcpp_string_gets_noexcept_iterator + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; + +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template struct __padding @@ -1198,7 +1238,7 @@ struct __padding<_CharT, 1> { }; -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template class _LIBCPP_TYPE_VIS_ONLY basic_string @@ -1234,7 +1274,7 @@ public: private: -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT struct __long { @@ -1294,7 +1334,7 @@ private: value_type __data_[__min_cap]; }; -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT union __ulx{__long __lx; __short __lxx;}; @@ -1377,8 +1417,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string& operator=(basic_string&& __str) - _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} basic_string& operator=(value_type __c); @@ -1480,15 +1519,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type append(_InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type append(_ForwardIterator __first, _ForwardIterator __last); @@ -1510,6 +1550,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string& assign(basic_string&& str) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {*this = _VSTD::move(str); return *this;} #endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); @@ -1519,15 +1560,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type assign(_InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type assign(_ForwardIterator __first, _ForwardIterator __last); @@ -1548,15 +1590,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, iterator >::type insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, iterator >::type insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); @@ -1698,7 +1741,7 @@ private: const allocator_type& __alloc() const _NOEXCEPT {return __r_.second();} -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT @@ -1716,7 +1759,7 @@ private: {return __r_.first().__s.__size_;} # endif -#else // _LIBCPP_ALTERNATE_STRING_LAYOUT +#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT @@ -1734,7 +1777,7 @@ private: {return __r_.first().__s.__size_ >> 1;} # endif -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_long_size(size_type __s) _NOEXCEPT @@ -1801,8 +1844,7 @@ private: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value, void >::type __init(_InputIterator __first, _InputIterator __last); @@ -1846,10 +1888,15 @@ private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - void __move_assign(basic_string& __str, false_type); + void __move_assign(basic_string& __str, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, true_type) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_assignable::value); +#endif #endif _LIBCPP_INLINE_VISIBILITY @@ -2174,8 +2221,7 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value, void >::type basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) @@ -2431,6 +2477,7 @@ template inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value) { if (__alloc() != __str.__alloc()) assign(__str); @@ -2442,7 +2489,11 @@ template inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_assignable::value) +#endif { clear(); shrink_to_fit(); @@ -2455,8 +2506,7 @@ template 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 && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__str, integral_constant()); @@ -2469,15 +2519,14 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator <_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { - clear(); - for (; __first != __last; ++__first) - push_back(*__first); + basic_string __temp(__first, __last, __alloc()); + assign(__temp.data(), __temp.size()); return *this; } @@ -2485,7 +2534,8 @@ template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) @@ -2618,14 +2668,14 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::append(_InputIterator __first, _InputIterator __last) { - for (; __first != __last; ++__first) - push_back(*__first); + basic_string __temp (__first, __last, __alloc()); + append(__temp.data(), __temp.size()); return *this; } @@ -2633,7 +2683,8 @@ template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) @@ -2749,9 +2800,9 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, - typename basic_string<_CharT, _Traits, _Allocator>::iterator + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, + typename basic_string<_CharT, _Traits, _Allocator>::iterator >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { @@ -2760,24 +2811,16 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt "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 + basic_string __temp(__first, __last, __alloc()); + return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) @@ -2980,22 +3023,8 @@ typename enable_if basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { - for (; true; ++__i1, ++__j1) - { - if (__i1 == __i2) - { - if (__j1 != __j2) - insert(__i1, __j1, __j2); - break; - } - if (__j1 == __j2) - { - erase(__i1, __i2); - break; - } - traits_type::assign(const_cast(*__i1), *__j1); - } - return *this; + basic_string __temp(__j1, __j2, __alloc()); + return this->replace(__i1, __i2, __temp); } template @@ -3788,7 +3817,11 @@ bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { - return __rhs.compare(__lhs) == 0; + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); + size_t __lhs_len = _Traits::length(__lhs); + if (__lhs_len != __rhs.size()) return false; + return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } template @@ -3797,7 +3830,11 @@ bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { - return __lhs.compare(__rhs) == 0; + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); + size_t __rhs_len = _Traits::length(__rhs); + if (__rhs_len != __lhs.size()) return false; + return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; } // operator!= diff --git a/contrib/libc++/include/thread b/contrib/libc++/include/thread index 8a30102f427e..6857e9edb68b 100644 --- a/contrib/libc++/include/thread +++ b/contrib/libc++/include/thread @@ -113,11 +113,38 @@ void sleep_for(const chrono::duration& rel_time); _LIBCPP_BEGIN_NAMESPACE_STD +template class __thread_specific_ptr; +class _LIBCPP_TYPE_VIS __thread_struct; +class _LIBCPP_HIDDEN __thread_struct_imp; +class __assoc_sub_state; + +_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); + +class _LIBCPP_TYPE_VIS __thread_struct +{ + __thread_struct_imp* __p_; + + __thread_struct(const __thread_struct&); + __thread_struct& operator=(const __thread_struct&); +public: + __thread_struct(); + ~__thread_struct(); + + void notify_all_at_thread_exit(condition_variable*, mutex*); + void __make_ready_at_thread_exit(__assoc_sub_state*); +}; + template class __thread_specific_ptr { pthread_key_t __key_; + // Only __thread_local_data() may construct a __thread_specific_ptr + // and only with _Tp == __thread_struct. + static_assert((is_same<_Tp, __thread_struct>::value), ""); + __thread_specific_ptr(); + friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); + __thread_specific_ptr(const __thread_specific_ptr&); __thread_specific_ptr& operator=(const __thread_specific_ptr&); @@ -125,7 +152,6 @@ class __thread_specific_ptr public: typedef _Tp* pointer; - __thread_specific_ptr(); ~__thread_specific_ptr(); _LIBCPP_INLINE_VISIBILITY @@ -159,7 +185,10 @@ __thread_specific_ptr<_Tp>::__thread_specific_ptr() template __thread_specific_ptr<_Tp>::~__thread_specific_ptr() { - pthread_key_delete(__key_); + // __thread_specific_ptr is only created with a static storage duration + // so this destructor is only invoked during program termination. Invoking + // pthread_key_delete(__key_) may prevent other threads from deleting their + // thread local data. For this reason we leak the key. } template @@ -289,6 +318,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = 0;} + _LIBCPP_INLINE_VISIBILITY thread& operator=(thread&& __t) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -307,26 +337,6 @@ public: static unsigned hardware_concurrency() _NOEXCEPT; }; -class __assoc_sub_state; - -class _LIBCPP_HIDDEN __thread_struct_imp; - -class _LIBCPP_TYPE_VIS __thread_struct -{ - __thread_struct_imp* __p_; - - __thread_struct(const __thread_struct&); - __thread_struct& operator=(const __thread_struct&); -public: - __thread_struct(); - ~__thread_struct(); - - void notify_all_at_thread_exit(condition_variable*, mutex*); - void __make_ready_at_thread_exit(__assoc_sub_state*); -}; - -_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); - #ifndef _LIBCPP_HAS_NO_VARIADICS template @@ -390,7 +400,7 @@ thread::thread(_Fp __f) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -inline _LIBCPP_INLINE_VISIBILITY +inline thread& thread::operator=(thread&& __t) _NOEXCEPT { diff --git a/contrib/libc++/include/tuple b/contrib/libc++/include/tuple index 3a22aa5ff5ac..cb1e27d93cf2 100644 --- a/contrib/libc++/include/tuple +++ b/contrib/libc++/include/tuple @@ -80,28 +80,33 @@ template tuple tuple_cat(Tuples&&... tpls); // cons // 20.4.1.4, tuple helper classes: template class tuple_size; // undefined template class tuple_size>; -template class tuple_element; // undefined -template class tuple_element>; -template - using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14 +template class tuple_element; // undefined +template class tuple_element>; +template + using tuple_element_t = typename tuple_element ::type; // C++14 // 20.4.1.5, element access: -template +template typename tuple_element>::type& get(tuple&) noexcept; // constexpr in C++14 -template - typename const tuple_element>::type & +template + const typename tuple_element>::type& get(const tuple&) noexcept; // constexpr in C++14 -template +template typename tuple_element>::type&& get(tuple&&) noexcept; // constexpr in C++14 +template + const typename tuple_element>::type&& + get(const tuple&&) noexcept; // constexpr in C++14 template constexpr T1& get(tuple&) noexcept; // C++14 template - constexpr T1 const& get(const tuple&) noexcept; // C++14 + constexpr const T1& get(const tuple&) noexcept; // C++14 template constexpr T1&& get(tuple&&) noexcept; // C++14 +template + constexpr const T1&& get(const tuple&&) noexcept; // C++14 // 20.4.1.6, relational operators: template bool operator==(const tuple&, const tuple&); // constexpr in C++14 @@ -507,6 +512,8 @@ class _LIBCPP_TYPE_VIS_ONLY tuple const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; + template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 + const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT; public: template && __t) _NOEXCEPT static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get()); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, tuple<_Tp...> >::type&& +get(const tuple<_Tp...>&& __t) _NOEXCEPT +{ + typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; + return static_cast( + static_cast&&>(__t.base_).get()); +} + #if _LIBCPP_STD_VER > 11 // get by type template @@ -822,6 +839,13 @@ constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__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>(_VSTD::move(__tup)); +} + #endif // tie diff --git a/contrib/libc++/include/type_traits b/contrib/libc++/include/type_traits index a0c1bc565c04..b7adfebceeb9 100644 --- a/contrib/libc++/include/type_traits +++ b/contrib/libc++/include/type_traits @@ -203,8 +203,160 @@ namespace std using result_of_t = typename result_of::type; // C++14 template - using void_t = void; -} // C++17 + using void_t = void; // C++17 + + // See C++14 20.10.4.1, primary type categories + template constexpr bool is_void_v + = is_void::value; // C++17 + template constexpr bool is_null_pointer_v + = is_null_pointer::value; // C++17 + template constexpr bool is_integral_v + = is_integral::value; // C++17 + template constexpr bool is_floating_point_v + = is_floating_point::value; // C++17 + template constexpr bool is_array_v + = is_array::value; // C++17 + template constexpr bool is_pointer_v + = is_pointer::value; // C++17 + template constexpr bool is_lvalue_reference_v + = is_lvalue_reference::value; // C++17 + template constexpr bool is_rvalue_reference_v + = is_rvalue_reference::value; // C++17 + template constexpr bool is_member_object_pointer_v + = is_member_object_pointer::value; // C++17 + template constexpr bool is_member_function_pointer_v + = is_member_function_pointer::value; // C++17 + template constexpr bool is_enum_v + = is_enum::value; // C++17 + template constexpr bool is_union_v + = is_union::value; // C++17 + template constexpr bool is_class_v + = is_class::value; // C++17 + template constexpr bool is_function_v + = is_function::value; // C++17 + + // See C++14 20.10.4.2, composite type categories + template constexpr bool is_reference_v + = is_reference::value; // C++17 + template constexpr bool is_arithmetic_v + = is_arithmetic::value; // C++17 + template constexpr bool is_fundamental_v + = is_fundamental::value; // C++17 + template constexpr bool is_object_v + = is_object::value; // C++17 + template constexpr bool is_scalar_v + = is_scalar::value; // C++17 + template constexpr bool is_compound_v + = is_compound::value; // C++17 + template constexpr bool is_member_pointer_v + = is_member_pointer::value; // C++17 + + // See C++14 20.10.4.3, type properties + template constexpr bool is_const_v + = is_const::value; // C++17 + template constexpr bool is_volatile_v + = is_volatile::value; // C++17 + template constexpr bool is_trivial_v + = is_trivial::value; // C++17 + template constexpr bool is_trivially_copyable_v + = is_trivially_copyable::value; // C++17 + template constexpr bool is_standard_layout_v + = is_standard_layout::value; // C++17 + template constexpr bool is_pod_v + = is_pod::value; // C++17 + template constexpr bool is_literal_type_v + = is_literal_type::value; // C++17 + template constexpr bool is_empty_v + = is_empty::value; // C++17 + template constexpr bool is_polymorphic_v + = is_polymorphic::value; // C++17 + template constexpr bool is_abstract_v + = is_abstract::value; // C++17 + template constexpr bool is_final_v + = is_final::value; // C++17 + template constexpr bool is_signed_v + = is_signed::value; // C++17 + template constexpr bool is_unsigned_v + = is_unsigned::value; // C++17 + template constexpr bool is_constructible_v + = is_constructible::value; // C++17 + template constexpr bool is_default_constructible_v + = is_default_constructible::value; // C++17 + template constexpr bool is_copy_constructible_v + = is_copy_constructible::value; // C++17 + template constexpr bool is_move_constructible_v + = is_move_constructible::value; // C++17 + template constexpr bool is_assignable_v + = is_assignable::value; // C++17 + template constexpr bool is_copy_assignable_v + = is_copy_assignable::value; // C++17 + template constexpr bool is_move_assignable_v + = is_move_assignable::value; // C++17 + template constexpr bool is_destructible_v + = is_destructible::value; // C++17 + template constexpr bool is_trivially_constructible_v + = is_trivially_constructible::value; // C++17 + template constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible::value; // C++17 + template constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible::value; // C++17 + template constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible::value; // C++17 + template constexpr bool is_trivially_assignable_v + = is_trivially_assignable::value; // C++17 + template constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable::value; // C++17 + template constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable::value; // C++17 + template constexpr bool is_trivially_destructible_v + = is_trivially_destructible::value; // C++17 + template constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible::value; // C++17 + template constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible::value; // C++17 + template constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible::value; // C++17 + template constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible::value; // C++17 + template constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable::value; // C++17 + template constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable::value; // C++17 + template constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable::value; // C++17 + template constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible::value; // C++17 + template constexpr bool has_virtual_destructor_v + = has_virtual_destructor::value; // C++17 + + // See C++14 20.10.5, type property queries + template constexpr size_t alignment_of_v + = alignment_of::value; // C++17 + template constexpr size_t rank_v + = rank::value; // C++17 + template constexpr size_t extent_v + = extent::value; // C++17 + + // See C++14 20.10.6, type relations + template constexpr bool is_same_v + = is_same::value; // C++17 + template constexpr bool is_base_of_v + = is_base_of::value; // C++17 + template constexpr bool is_convertible_v + = is_convertible::value; // C++17 + + // [meta.logical], logical operator traits: + template struct conjunction; // C++17 + template + constexpr bool conjunction_v = conjunction::value; // C++17 + template struct disjunction; // C++17 + template + constexpr bool disjunction_v = disjunction::value; // C++17 + template struct negation; // C++17 + template + constexpr bool negation_v = negation::value; // C++17 + +} */ #include <__config> @@ -244,6 +396,55 @@ template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef template using enable_if_t = typename enable_if<_Bp, _Tp>::type; #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 struct __two {char __lx[2];}; @@ -269,24 +470,111 @@ _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; #if _LIBCPP_STD_VER > 14 template using bool_constant = integral_constant; -#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> +#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> #else -#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant +#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant #endif typedef _LIBCPP_BOOL_CONSTANT(true) true_type; typedef _LIBCPP_BOOL_CONSTANT(false) false_type; +#if !defined(_LIBCPP_HAS_NO_VARIADICS) + +// __lazy_and + +template +struct __lazy_and_impl; + +template +struct __lazy_and_impl : false_type {}; + +template <> +struct __lazy_and_impl : true_type {}; + +template +struct __lazy_and_impl : integral_constant {}; + +template +struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_or + +template +struct __lazy_or_impl; + +template +struct __lazy_or_impl : true_type {}; + +template <> +struct __lazy_or_impl : false_type {}; + +template +struct __lazy_or_impl + : __lazy_or_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template +struct __lazy_not : integral_constant {}; + +// __and_ +template struct __and_; +template<> struct __and_<> : true_type {}; + +template struct __and_<_B0> : _B0 {}; + +template +struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; + +template +struct __and_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; + +// __or_ +template struct __or_; +template<> struct __or_<> : false_type {}; + +template struct __or_<_B0> : _B0 {}; + +template +struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; + +template +struct __or_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; + +// __not_ +template +struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; + +#endif // !defined(_LIBCPP_HAS_NO_VARIADICS) + // is_const template struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; +#endif + // is_volatile template struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; +#endif + // remove_const template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; @@ -319,6 +607,11 @@ template <> struct __libcpp_is_void : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; +#endif + // __is_nullptr_t template struct __is_nullptr_t_impl : public false_type {}; @@ -330,6 +623,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer : public __is_nullptr_t_impl::type> {}; + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; +#endif #endif // is_integral @@ -360,6 +658,11 @@ template <> struct __libcpp_is_integral<__uint128_t> : public tr template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; +#endif + // is_floating_point template struct __libcpp_is_floating_point : public false_type {}; @@ -370,6 +673,11 @@ template <> struct __libcpp_is_floating_point : public tru template struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; +#endif + // is_array template struct _LIBCPP_TYPE_VIS_ONLY is_array @@ -379,6 +687,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; +#endif + // is_pointer template struct __libcpp_is_pointer : public false_type {}; @@ -387,6 +700,11 @@ template struct __libcpp_is_pointer<_Tp*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; +#endif + // is_reference template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; @@ -403,6 +721,16 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public t template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; +#endif // is_union #if __has_feature(is_union) || (_GNUC_VER >= 403) @@ -418,6 +746,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_union #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; +#endif + // is_class #if __has_feature(is_class) || (_GNUC_VER >= 403) @@ -438,11 +771,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_class #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; +#endif + // is_same template struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; +#endif + // is_function namespace __libcpp_is_function_imp @@ -468,13 +811,18 @@ template struct __libcpp_is_function<_Tp, true> : public false_type template struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; +#endif + // is_member_function_pointer // template struct __libcpp_is_member_function_pointer : public false_type {}; // template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; // -template +template struct __member_pointer_traits_imp { // forward declaration; specializations later }; @@ -490,6 +838,11 @@ struct __libcpp_is_member_function_pointer<_Ret _Class::*> template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type>::type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; +#endif + // is_member_pointer template struct __libcpp_is_member_pointer : public false_type {}; @@ -498,12 +851,22 @@ template struct __libcpp_is_member_pointer<_Tp _Up::*> : template struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; +#endif + // is_member_object_pointer template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant::value && !is_member_function_pointer<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; +#endif + // is_enum #if __has_feature(is_enum) || (_GNUC_VER >= 403) @@ -527,12 +890,22 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_enum #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; +#endif + // is_arithmetic template struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; +#endif + // is_fundamental template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental @@ -540,6 +913,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; +#endif + // is_scalar template struct _LIBCPP_TYPE_VIS_ONLY is_scalar @@ -551,6 +929,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_scalar template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; +#endif + // is_object template struct _LIBCPP_TYPE_VIS_ONLY is_object @@ -559,11 +942,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_object is_union<_Tp>::value || is_class<_Tp>::value > {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; +#endif + // is_compound template struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; +#endif + // add_const template ::value || @@ -701,6 +1094,11 @@ template struct __libcpp_is_signed<_Tp, false> : public false_type { template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; +#endif + // is_unsigned template ::value> @@ -716,6 +1114,11 @@ template struct __libcpp_is_unsigned<_Tp, false> : public false_type template struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; +#endif + // rank template struct _LIBCPP_TYPE_VIS_ONLY rank @@ -725,6 +1128,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant::value + 1> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; +#endif + // extent template struct _LIBCPP_TYPE_VIS_ONLY extent @@ -738,6 +1146,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0 template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Ip>::value; +#endif + // remove_extent template struct _LIBCPP_TYPE_VIS_ONLY remove_extent @@ -804,6 +1217,11 @@ template struct __libcpp_abstract<_Tp, false> : public false_type {} template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; +#endif + // is_final #if defined(_LIBCPP_HAS_IS_FINAL) @@ -819,6 +1237,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_final : public integral_constant {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; +#endif + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF @@ -854,6 +1277,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of #endif // _LIBCPP_HAS_IS_BASE_OF +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Bp, _Dp>::value; +#endif + // is_convertible #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) @@ -981,6 +1409,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_convertible #endif // __has_feature(is_convertible_to) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_From, _To>::value; +#endif + // is_empty #if __has_feature(is_empty) || (_GNUC_VER >= 407) @@ -1012,6 +1445,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_emp #endif // __has_feature(is_empty) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; +#endif + // is_polymorphic #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC) @@ -1032,6 +1470,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic #endif // __has_feature(is_polymorphic) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; +#endif + // has_virtual_destructor #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) @@ -1046,11 +1489,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; +#endif + // alignment_of template struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; +#endif + // aligned_storage template @@ -1143,7 +1596,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage union type { _Aligner __align; - unsigned char __data[_Len]; + unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; }; }; @@ -1158,7 +1611,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ - unsigned char __lx[_Len];\ + unsigned char __lx[(_Len + n - 1)/n * n];\ };\ } @@ -1290,18 +1743,6 @@ public: template class __promote : public __promote_imp<_A1, _A2, _A3> {}; -#ifdef _LIBCPP_STORE_AS_OPTIMIZATION - -// __transform - -template ::value> struct __transform {typedef _Tp type;}; -template struct __transform<_Tp, 1, true> {typedef unsigned char type;}; -template struct __transform<_Tp, 2, true> {typedef unsigned short type;}; -template struct __transform<_Tp, 4, true> {typedef unsigned int type;}; -template struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; - -#endif // _LIBCPP_STORE_AS_OPTIMIZATION - // make_signed / make_unsigned typedef @@ -1482,21 +1923,19 @@ public: template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { -private: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp&& __t(); - static _Up&& __u(); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp __t(); - static _Up __u(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - typedef typename remove_reference::type type; + typedef typename decay() : _VSTD::declval<_Up>() + )>::type type; }; #else // _LIBCPP_HAS_NO_VARIADICS -template struct common_type; +// bullet 1 - sizeof...(Tp) == 0 + +template +struct _LIBCPP_TYPE_VIS_ONLY common_type {}; + +// bullet 2 - sizeof...(Tp) == 1 template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> @@ -1504,22 +1943,45 @@ struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> typedef typename decay<_Tp>::type type; }; +// bullet 3 - sizeof...(Tp) == 2 + +template +struct __common_type2 {}; + +template +struct __common_type2<_Tp, _Up, + typename __void_t() : _VSTD::declval<_Up>() + )>::type> +{ + typedef typename decay() : _VSTD::declval<_Up>() + )>::type type; +}; + template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> + : __common_type2<_Tp, _Up> {}; + +// bullet 4 - sizeof...(Tp) > 2 + +template struct __common_types; + +template +struct __common_type_impl {}; + +template +struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>, + typename __void_t::type>::type> { -private: - static _Tp&& __t(); - static _Up&& __u(); - static bool __f(); -public: - typedef typename decay::type type; + typedef typename common_type< + typename common_type<_Tp, _Up>::type, _Vp... + >::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> -{ - typedef typename common_type::type, _Vp...>::type type; -}; + : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {}; #if _LIBCPP_STD_VER > 11 template using common_type_t = typename common_type<_Tp...>::type; @@ -1564,12 +2026,22 @@ template struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Arg>::value; +#endif + // is_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; +#endif + // is_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable @@ -1580,6 +2052,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable : public is_copy_assignable<_Tp> {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; +#endif + // is_destructible // if it's a reference, return true @@ -1638,6 +2115,11 @@ template <> struct is_destructible : public _VSTD::false_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; +#endif + // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2672,6 +3154,11 @@ struct __is_constructible2_imp #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Args...>::value; +#endif + // is_default_constructible template @@ -2679,6 +3166,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; +#endif + // is_copy_constructible template @@ -2686,6 +3178,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; +#endif + // is_move_constructible template @@ -2697,6 +3194,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; +#endif + // is_trivially_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2824,18 +3326,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Args...>::value; +#endif + // is_trivially_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; +#endif + // is_trivially_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; +#endif + // is_trivially_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible @@ -2846,6 +3363,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; +#endif + // is_trivially_assignable #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 @@ -2884,12 +3406,22 @@ struct is_trivially_assignable<_Tp&, _Tp&&> #endif // !__has_feature(is_trivially_assignable) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Arg>::value; +#endif + // is_trivially_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; +#endif + // is_trivially_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable @@ -2901,6 +3433,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; +#endif + // is_trivially_destructible #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) @@ -2917,6 +3454,14 @@ template struct __libcpp_trivial_destructor template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; #endif // is_nothrow_constructible @@ -3079,18 +3624,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_nothrow_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Args...>::value; +#endif + // is_nothrow_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; +#endif + // is_nothrow_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; +#endif + // is_nothrow_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible @@ -3101,6 +3661,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; +#endif + // is_nothrow_assignable #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3169,12 +3734,22 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> #endif // __has_feature(cxx_noexcept) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Arg>::value; +#endif + // is_nothrow_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; +#endif + // is_nothrow_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable @@ -3186,6 +3761,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; +#endif + // is_nothrow_destructible #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3241,6 +3821,15 @@ template struct __libcpp_nothrow_destructor template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; +template +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; #endif // is_pod @@ -3260,6 +3849,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_pod #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; +#endif + // is_literal_type; template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type @@ -3271,6 +3865,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; +#endif + // is_standard_layout; template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout @@ -3281,6 +3880,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; +#endif + // is_trivially_copyable; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable @@ -3293,6 +3897,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; +#endif + // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial @@ -3304,6 +3913,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivial #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; +#endif + #ifndef _LIBCPP_HAS_NO_VARIADICS // Check for complete types @@ -3692,34 +4306,34 @@ struct __sfinae_underlying_type template struct __sfinae_underlying_type<_Tp, false> {}; -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY int __convert_to_integral(int __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned __convert_to_integral(unsigned __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long __convert_to_integral(long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long __convert_to_integral(unsigned long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long long __convert_to_integral(long long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } #ifndef _LIBCPP_HAS_NO_INT128 -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __int128_t __convert_to_integral(__int128_t __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } #endif template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY typename __sfinae_underlying_type<_Tp>::__promoted_type __convert_to_integral(_Tp __val) { return __val; } @@ -3759,7 +4373,21 @@ struct __has_operator_addressof #if _LIBCPP_STD_VER > 14 template using void_t = void; -#endif + +# ifndef _LIBCPP_HAS_NO_VARIADICS +template +struct conjunction : __and_<_Args...> {}; +template constexpr bool conjunction_v = conjunction<_Args...>::value; + +template +struct disjunction : __or_<_Args...> {}; +template constexpr bool disjunction_v = disjunction<_Args...>::value; + +template +struct negation : __not_<_Tp> {}; +template constexpr bool negation_v = negation<_Tp>::value; +# endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libc++/include/unordered_map b/contrib/libc++/include/unordered_map index cf70ab62f69e..85a54a7b6ddb 100644 --- a/contrib/libc++/include/unordered_map +++ b/contrib/libc++/include/unordered_map @@ -656,7 +656,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::value_type::first_type key_type; typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: @@ -664,13 +663,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() _NOEXCEPT {} @@ -712,7 +706,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::value_type::first_type key_type; typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: @@ -720,13 +713,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() _NOEXCEPT {} @@ -1511,7 +1499,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); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template diff --git a/contrib/libc++/include/utility b/contrib/libc++/include/utility index 54cfc8bc1592..c9f5785b3d4e 100644 --- a/contrib/libc++/include/utility +++ b/contrib/libc++/include/utility @@ -52,6 +52,9 @@ template >::type move_if_noexcept(T& x) noexcept; // constexpr in C++14 +template constexpr add_const_t& as_const(T& t) noexcept; // C++17 +template void as_const(const T&&) = delete; // C++17 + template typename add_rvalue_reference::type declval() noexcept; template @@ -110,22 +113,41 @@ template get(pair&) noexcept; // constexpr in C++14 template - const typename const tuple_element >::type& + const typename tuple_element >::type& get(const pair&) noexcept; // constexpr in C++14 template typename tuple_element >::type&& get(pair&&) noexcept; // constexpr in C++14 +template + const typename tuple_element >::type&& + get(const pair&&) noexcept; // constexpr in C++14 + template constexpr T1& get(pair&) noexcept; // C++14 -template - constexpr T1 const& get(pair const &) noexcept; // C++14 +template + constexpr const T1& get(const pair&) noexcept; // C++14 -template +template constexpr T1&& get(pair&&) noexcept; // C++14 +template + constexpr const T1&& get(const pair&&) noexcept; // C++14 + +template + constexpr T1& get(pair&) noexcept; // C++14 + +template + constexpr const T1& get(const pair&) noexcept; // C++14 + +template + constexpr T1&& get(pair&&) noexcept; // C++14 + +template + constexpr const T1&& get(const pair&&) noexcept; // C++14 + // C++14 template @@ -242,6 +264,11 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT return _VSTD::move(__x); } +#if _LIBCPP_STD_VER > 14 +template constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; } +template void as_const(const _Tp&&) = delete; +#endif + 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(); @@ -261,6 +288,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pair // pair(const pair&) = default; // pair(pair&&) = default; +#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS + template , _Dummy>::value && + __dependent_type, _Dummy>::value + >::type> +#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -388,8 +421,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) { - _VSTD::iter_swap(&first, &__p.first); - _VSTD::iter_swap(&second, &__p.second); + using _VSTD::swap; + swap(first, __p.first); + swap(second, __p.second); } private: @@ -551,6 +585,12 @@ struct __get_pair<0> _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} + template + static + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _T1&& + get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.first);} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }; @@ -577,6 +617,12 @@ struct __get_pair<1> _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} + template + static + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _T2&& + get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.second);} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }; @@ -606,6 +652,14 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT return __get_pair<_Ip>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& +get(const pair<_T1, _T2>&& __p) _NOEXCEPT +{ + return __get_pair<_Ip>::get(_VSTD::move(__p)); +} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #if _LIBCPP_STD_VER > 11 @@ -630,6 +684,13 @@ constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT return __get_pair<0>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT +{ + return __get_pair<0>::get(_VSTD::move(__p)); +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT @@ -651,6 +712,13 @@ constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT return __get_pair<1>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT +{ + return __get_pair<1>::get(_VSTD::move(__p)); +} + #endif #if _LIBCPP_STD_VER > 11 @@ -671,6 +739,16 @@ struct _LIBCPP_TYPE_VIS_ONLY integer_sequence template using index_sequence = integer_sequence; +#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) + +template +struct __make_integer_sequence +{ + typedef __make_integer_seq type; +}; + +#else + namespace __detail { template struct __repeat; @@ -724,10 +802,14 @@ struct __make_integer_sequence { static_assert(is_integral<_Tp>::value, "std::make_integer_sequence can only be instantiated with an integral type" ); - static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative"); - typedef __make_integer_sequence_unchecked<_Tp, _Ep> type; + static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length"); + // Workaround GCC bug by preventing bad installations when 0 <= _Ep + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929 + typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; }; +#endif + template using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type; diff --git a/contrib/libc++/include/valarray b/contrib/libc++/include/valarray index bdaa58836f39..bde644e8719b 100644 --- a/contrib/libc++/include/valarray +++ b/contrib/libc++/include/valarray @@ -802,11 +802,14 @@ public: // construct/destroy: _LIBCPP_INLINE_VISIBILITY valarray() : __begin_(0), __end_(0) {} - explicit valarray(size_t __n); + _LIBCPP_INLINE_VISIBILITY + inline explicit valarray(size_t __n); + _LIBCPP_INLINE_VISIBILITY valarray(const value_type& __x, size_t __n); valarray(const value_type* __p, size_t __n); valarray(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY valarray(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -816,22 +819,31 @@ public: valarray(const gslice_array& __ga); valarray(const mask_array& __ma); valarray(const indirect_array& __ia); + inline _LIBCPP_INLINE_VISIBILITY ~valarray(); // assignment: valarray& operator=(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY valarray& operator=(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY valarray& operator=(initializer_list); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const slice_array& __sa); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const gslice_array& __ga); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const mask_array& __ma); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const indirect_array& __ia); template + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const __val_expr<_ValExpr>& __v); // element access: @@ -842,24 +854,38 @@ public: value_type& operator[](size_t __i) {return __begin_[__i];} // subset operations: + _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr > operator[](slice __s) const; + _LIBCPP_INLINE_VISIBILITY slice_array operator[](slice __s); + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](const gslice& __gs) const; + _LIBCPP_INLINE_VISIBILITY gslice_array operator[](const gslice& __gs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](gslice&& __gs) const; + _LIBCPP_INLINE_VISIBILITY gslice_array operator[](gslice&& __gs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr > operator[](const valarray& __vb) const; + _LIBCPP_INLINE_VISIBILITY mask_array operator[](const valarray& __vb); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr > operator[](valarray&& __vb) const; + _LIBCPP_INLINE_VISIBILITY mask_array operator[](valarray&& __vb); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](const valarray& __vs) const; + _LIBCPP_INLINE_VISIBILITY indirect_array operator[](const valarray& __vs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](valarray&& __vs) const; + _LIBCPP_INLINE_VISIBILITY indirect_array operator[](valarray&& __vs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -870,15 +896,25 @@ public: valarray operator!() const; // computed assignment: + _LIBCPP_INLINE_VISIBILITY valarray& operator*= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator/= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator%= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator+= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator-= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator^= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator&= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator|= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator<<=(const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator>>=(const value_type& __x); template @@ -887,6 +923,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator*= (const _Expr& __v); template @@ -895,6 +932,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator/= (const _Expr& __v); template @@ -903,6 +941,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator%= (const _Expr& __v); template @@ -911,6 +950,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator+= (const _Expr& __v); template @@ -919,6 +959,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator-= (const _Expr& __v); template @@ -927,6 +968,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator^= (const _Expr& __v); template @@ -935,6 +977,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator|= (const _Expr& __v); template @@ -943,6 +986,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator&= (const _Expr& __v); template @@ -951,6 +995,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator<<= (const _Expr& __v); template @@ -959,16 +1004,21 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator>>= (const _Expr& __v); // member functions: + _LIBCPP_INLINE_VISIBILITY void swap(valarray& __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_t size() const {return static_cast(__end_ - __begin_);} + _LIBCPP_INLINE_VISIBILITY value_type sum() const; + _LIBCPP_INLINE_VISIBILITY value_type min() const; + _LIBCPP_INLINE_VISIBILITY value_type max() const; valarray shift (int __i) const; @@ -1114,6 +1164,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1122,6 +1173,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1130,6 +1182,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1138,6 +1191,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1146,6 +1200,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1154,6 +1209,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1162,6 +1218,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1170,6 +1227,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1178,6 +1236,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1186,6 +1245,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1194,10 +1254,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const slice_array& operator=(const slice_array& __sa) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; private: @@ -1213,7 +1276,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const { @@ -1226,7 +1289,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1241,7 +1304,7 @@ slice_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1256,7 +1319,7 @@ slice_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1271,7 +1334,7 @@ slice_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1286,7 +1349,7 @@ slice_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1301,7 +1364,7 @@ slice_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1316,7 +1379,7 @@ slice_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1331,7 +1394,7 @@ slice_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1346,7 +1409,7 @@ slice_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1361,7 +1424,7 @@ slice_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1376,7 +1439,7 @@ slice_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1390,7 +1453,7 @@ slice_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void slice_array<_Tp>::operator=(const value_type& __x) const { @@ -1484,6 +1547,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1492,6 +1556,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1500,6 +1565,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1508,6 +1574,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1516,6 +1583,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1524,6 +1592,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1532,6 +1601,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1540,6 +1610,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1548,6 +1619,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1556,6 +1628,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1564,10 +1637,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const gslice_array& operator=(const gslice_array& __ga) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // gslice_array(const gslice_array&) = default; @@ -1576,20 +1652,16 @@ public: // gslice_array& operator=(gslice_array&&) = default; private: - _LIBCPP_INLINE_VISIBILITY gslice_array(const gslice& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(__gs.__1d_) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - - _LIBCPP_INLINE_VISIBILITY gslice_array(gslice&& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(move(__gs.__1d_)) {} - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend class valarray; @@ -1597,7 +1669,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1613,7 +1685,7 @@ gslice_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1629,7 +1701,7 @@ gslice_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1645,7 +1717,7 @@ gslice_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1661,7 +1733,7 @@ gslice_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1677,7 +1749,7 @@ gslice_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1693,7 +1765,7 @@ gslice_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1709,7 +1781,7 @@ gslice_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1725,7 +1797,7 @@ gslice_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1741,7 +1813,7 @@ gslice_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1757,7 +1829,7 @@ gslice_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1772,7 +1844,7 @@ gslice_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const { @@ -1785,7 +1857,7 @@ gslice_array<_Tp>::operator=(const gslice_array& __ga) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void gslice_array<_Tp>::operator=(const value_type& __x) const { @@ -1813,6 +1885,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1821,6 +1894,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1829,6 +1903,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1837,6 +1912,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1845,6 +1921,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1853,6 +1930,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1861,6 +1939,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1869,6 +1948,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1877,6 +1957,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1885,6 +1966,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1893,10 +1975,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const mask_array& operator=(const mask_array& __ma) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // mask_array(const mask_array&) = default; @@ -1921,7 +2006,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1936,7 +2021,7 @@ mask_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1951,7 +2036,7 @@ mask_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1966,7 +2051,7 @@ mask_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1981,7 +2066,7 @@ mask_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1996,7 +2081,7 @@ mask_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2011,7 +2096,7 @@ mask_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2026,7 +2111,7 @@ mask_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2041,7 +2126,7 @@ mask_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2056,7 +2141,7 @@ mask_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2071,7 +2156,7 @@ mask_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2085,7 +2170,7 @@ mask_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const { @@ -2096,7 +2181,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void mask_array<_Tp>::operator=(const value_type& __x) const { @@ -2158,6 +2243,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -2166,6 +2252,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -2174,6 +2261,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -2182,6 +2270,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -2190,6 +2279,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -2198,6 +2288,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -2206,6 +2297,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -2214,6 +2306,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -2222,6 +2315,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -2230,6 +2324,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -2238,10 +2333,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const indirect_array& operator=(const indirect_array& __ia) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // indirect_array(const indirect_array&) = default; @@ -2271,7 +2369,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2286,7 +2384,7 @@ indirect_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2301,7 +2399,7 @@ indirect_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2316,7 +2414,7 @@ indirect_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2331,7 +2429,7 @@ indirect_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2346,7 +2444,7 @@ indirect_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2361,7 +2459,7 @@ indirect_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2376,7 +2474,7 @@ indirect_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2391,7 +2489,7 @@ indirect_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2406,7 +2504,7 @@ indirect_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2421,7 +2519,7 @@ indirect_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2435,7 +2533,7 @@ indirect_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const { @@ -2448,7 +2546,7 @@ indirect_array<_Tp>::operator=(const indirect_array& __ia) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void indirect_array<_Tp>::operator=(const value_type& __x) const { @@ -2650,7 +2748,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const // valarray template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(size_t __n) : __begin_(0), __end_(0) @@ -2659,7 +2757,7 @@ valarray<_Tp>::valarray(size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(0), __end_(0) @@ -2720,7 +2818,7 @@ valarray<_Tp>::valarray(const valarray& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) @@ -2874,7 +2972,7 @@ valarray<_Tp>::valarray(const indirect_array& __ia) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::~valarray() { resize(0); @@ -2896,7 +2994,7 @@ valarray<_Tp>::operator=(const valarray& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { @@ -2913,7 +3011,7 @@ valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list __il) { @@ -2926,7 +3024,7 @@ valarray<_Tp>::operator=(initializer_list __il) #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { @@ -2935,7 +3033,7 @@ valarray<_Tp>::operator=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array& __sa) { @@ -2947,7 +3045,7 @@ valarray<_Tp>::operator=(const slice_array& __sa) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array& __ga) { @@ -2961,7 +3059,7 @@ valarray<_Tp>::operator=(const gslice_array& __ga) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array& __ma) { @@ -2975,7 +3073,7 @@ valarray<_Tp>::operator=(const mask_array& __ma) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array& __ia) { @@ -2990,7 +3088,7 @@ valarray<_Tp>::operator=(const indirect_array& __ia) template template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) { @@ -3004,7 +3102,7 @@ valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__slice_expr&> > valarray<_Tp>::operator[](slice __s) const { @@ -3012,7 +3110,7 @@ valarray<_Tp>::operator[](slice __s) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) { @@ -3020,7 +3118,7 @@ valarray<_Tp>::operator[](slice __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const gslice& __gs) const { @@ -3028,7 +3126,7 @@ valarray<_Tp>::operator[](const gslice& __gs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { @@ -3038,7 +3136,7 @@ valarray<_Tp>::operator[](const gslice& __gs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](gslice&& __gs) const { @@ -3046,7 +3144,7 @@ valarray<_Tp>::operator[](gslice&& __gs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) { @@ -3056,7 +3154,7 @@ valarray<_Tp>::operator[](gslice&& __gs) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__mask_expr&> > valarray<_Tp>::operator[](const valarray& __vb) const { @@ -3064,7 +3162,7 @@ valarray<_Tp>::operator[](const valarray& __vb) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray& __vb) { @@ -3074,7 +3172,7 @@ valarray<_Tp>::operator[](const valarray& __vb) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__mask_expr&> > valarray<_Tp>::operator[](valarray&& __vb) const { @@ -3082,7 +3180,7 @@ valarray<_Tp>::operator[](valarray&& __vb) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline mask_array<_Tp> valarray<_Tp>::operator[](valarray&& __vb) { @@ -3092,7 +3190,7 @@ valarray<_Tp>::operator[](valarray&& __vb) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const valarray& __vs) const { @@ -3100,7 +3198,7 @@ valarray<_Tp>::operator[](const valarray& __vs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray& __vs) { @@ -3110,7 +3208,7 @@ valarray<_Tp>::operator[](const valarray& __vs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](valarray&& __vs) const { @@ -3118,7 +3216,7 @@ valarray<_Tp>::operator[](valarray&& __vs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray&& __vs) { @@ -3196,7 +3294,7 @@ valarray<_Tp>::operator!() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) { @@ -3206,7 +3304,7 @@ valarray<_Tp>::operator*=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) { @@ -3216,7 +3314,7 @@ valarray<_Tp>::operator/=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) { @@ -3226,7 +3324,7 @@ valarray<_Tp>::operator%=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) { @@ -3236,7 +3334,7 @@ valarray<_Tp>::operator+=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) { @@ -3246,7 +3344,7 @@ valarray<_Tp>::operator-=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) { @@ -3256,7 +3354,7 @@ valarray<_Tp>::operator^=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) { @@ -3266,7 +3364,7 @@ valarray<_Tp>::operator&=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) { @@ -3276,7 +3374,7 @@ valarray<_Tp>::operator|=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) { @@ -3286,7 +3384,7 @@ valarray<_Tp>::operator<<=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) { @@ -3297,7 +3395,7 @@ valarray<_Tp>::operator>>=(const value_type& __x) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3313,7 +3411,7 @@ valarray<_Tp>::operator*=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3329,7 +3427,7 @@ valarray<_Tp>::operator/=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3345,7 +3443,7 @@ valarray<_Tp>::operator%=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3361,7 +3459,7 @@ valarray<_Tp>::operator+=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3377,7 +3475,7 @@ valarray<_Tp>::operator-=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3393,7 +3491,7 @@ valarray<_Tp>::operator^=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3409,7 +3507,7 @@ valarray<_Tp>::operator|=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3425,7 +3523,7 @@ valarray<_Tp>::operator&=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3441,7 +3539,7 @@ valarray<_Tp>::operator<<=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3456,7 +3554,7 @@ valarray<_Tp>::operator>>=(const _Expr& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT { @@ -3465,7 +3563,7 @@ valarray<_Tp>::swap(valarray& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::sum() const { @@ -3479,7 +3577,7 @@ valarray<_Tp>::sum() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::min() const { @@ -3489,7 +3587,7 @@ valarray<_Tp>::min() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::max() const { diff --git a/contrib/libc++/include/vector b/contrib/libc++/include/vector index c168c8ea60ad..dbc0dd321824 100644 --- a/contrib/libc++/include/vector +++ b/contrib/libc++/include/vector @@ -51,8 +51,8 @@ public: vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value); // C++17 vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); @@ -175,8 +175,8 @@ public: vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value); // C++17 vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); @@ -562,9 +562,7 @@ public: vector(vector&& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY @@ -687,9 +685,11 @@ public: _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); #ifndef _LIBCPP_HAS_NO_VARIADICS template + _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY void pop_back(); iterator insert(const_iterator __position, const_reference __x); @@ -768,6 +768,7 @@ private: void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; void __construct_at_end(size_type __n); + _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, const_reference __x); template typename enable_if @@ -787,7 +788,8 @@ private: void __move_range(pointer __from_s, pointer __from_e, pointer __to); void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); - void __move_assign(vector& __c, false_type); + void __move_assign(vector& __c, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -991,7 +993,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 -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -1303,9 +1305,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__x, integral_constant()); @@ -1315,6 +1315,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x) template void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value) { if (__base::__alloc() != __c.__alloc()) { @@ -1629,7 +1630,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template template -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -1650,7 +1651,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::pop_back() { @@ -1897,9 +1898,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs pointer __old_last = this->__end_; for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); ++this->__end_; + __annotator.__done(); } __split_buffer __v(__a); if (__first != __last) @@ -2211,9 +2214,7 @@ public: vector(vector&& __v, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY @@ -2836,9 +2837,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector& vector::operator=(vector&& __v) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__v, integral_constant()); diff --git a/contrib/libc++/include/wchar.h b/contrib/libc++/include/wchar.h new file mode 100644 index 000000000000..da34f735edf3 --- /dev/null +++ b/contrib/libc++/include/wchar.h @@ -0,0 +1,136 @@ +// -*- C++ -*- +//===--------------------------- wchar.h ----------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_wint_t) || defined(__need_mbstate_t) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_WCHAR_H) +#define _LIBCPP_WCHAR_H + +/* + wchar.h synopsis + +Macros: + + NULL + WCHAR_MAX + WCHAR_MIN + WEOF + +Types: + + mbstate_t + size_t + tm + wint_t + +int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...); +int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...); +int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...); +int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...); +int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); +int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99 +int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg); +int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99 +int vwprintf(const wchar_t* restrict format, va_list arg); +int vwscanf(const wchar_t* restrict format, va_list arg); // C99 +int wprintf(const wchar_t* restrict format, ...); +int wscanf(const wchar_t* restrict format, ...); +wint_t fgetwc(FILE* stream); +wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream); +wint_t fputwc(wchar_t c, FILE* stream); +int fputws(const wchar_t* restrict s, FILE* restrict stream); +int fwide(FILE* stream, int mode); +wint_t getwc(FILE* stream); +wint_t getwchar(); +wint_t putwc(wchar_t c, FILE* stream); +wint_t putwchar(wchar_t c); +wint_t ungetwc(wint_t c, FILE* stream); +double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr); +float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 +long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 +long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 +unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 +wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2); +wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2); +wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +int wcscmp(const wchar_t* s1, const wchar_t* s2); +int wcscoll(const wchar_t* s1, const wchar_t* s2); +int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n); +size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +const wchar_t* wcschr(const wchar_t* s, wchar_t c); + wchar_t* wcschr( wchar_t* s, wchar_t c); +size_t wcscspn(const wchar_t* s1, const wchar_t* s2); +size_t wcslen(const wchar_t* s); +const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); + wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2); +const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); + wchar_t* wcsrchr( wchar_t* s, wchar_t c); +size_t wcsspn(const wchar_t* s1, const wchar_t* s2); +const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); + wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2); +wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr); +const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); + wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n); +int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); +wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); +size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format, + const tm* restrict timeptr); +wint_t btowc(int c); +int wctob(wint_t c); +int mbsinit(const mbstate_t* ps); +size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps); +size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps); +size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps); +size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len, + mbstate_t* restrict ps); +size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, + mbstate_t* restrict ps); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#ifdef __cplusplus +#define __CORRECT_ISO_CPP_WCHAR_H_PROTO +#endif + +#include_next + +// Let know if we have const-correct overloads for wcschr and friends. +#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +#elif defined(__GLIBC_PREREQ) +# if __GLIBC_PREREQ(2, 10) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +# endif +#endif + +#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)) +extern "C++" { +#include // pull in *swprintf defines +} // extern "C++" +#endif // __cplusplus && _LIBCPP_MSVCRT + +#endif // _LIBCPP_WCHAR_H diff --git a/contrib/libc++/include/wctype.h b/contrib/libc++/include/wctype.h new file mode 100644 index 000000000000..f9c5a47754bb --- /dev/null +++ b/contrib/libc++/include/wctype.h @@ -0,0 +1,79 @@ +// -*- C++ -*- +//===--------------------------- wctype.h ---------------------------------===// +// +// 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_WCTYPE_H +#define _LIBCPP_WCTYPE_H + +/* + wctype.h synopsis + +Macros: + + WEOF + +Types: + + wint_t + wctrans_t + wctype_t + +int iswalnum(wint_t wc); +int iswalpha(wint_t wc); +int iswblank(wint_t wc); // C99 +int iswcntrl(wint_t wc); +int iswdigit(wint_t wc); +int iswgraph(wint_t wc); +int iswlower(wint_t wc); +int iswprint(wint_t wc); +int iswpunct(wint_t wc); +int iswspace(wint_t wc); +int iswupper(wint_t wc); +int iswxdigit(wint_t wc); +int iswctype(wint_t wc, wctype_t desc); +wctype_t wctype(const char* property); +wint_t towlower(wint_t wc); +wint_t towupper(wint_t wc); +wint_t towctrans(wint_t wc, wctrans_t desc); +wctrans_t wctrans(const char* property); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef wctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans + +#endif // __cplusplus + +#endif // _LIBCPP_WCTYPE_H diff --git a/contrib/libc++/src/any.cpp b/contrib/libc++/src/any.cpp new file mode 100644 index 000000000000..f77684578905 --- /dev/null +++ b/contrib/libc++/src/any.cpp @@ -0,0 +1,18 @@ +//===---------------------------- any.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/any" + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +const char* bad_any_cast::what() const _NOEXCEPT { + return "bad any cast"; +} + +_LIBCPP_END_NAMESPACE_LFTS diff --git a/contrib/libc++/src/exception.cpp b/contrib/libc++/src/exception.cpp index 2c16060a7583..e172f642d483 100644 --- a/contrib/libc++/src/exception.cpp +++ b/contrib/libc++/src/exception.cpp @@ -12,10 +12,6 @@ #include "exception" #include "new" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - #if defined(__APPLE__) && !defined(LIBCXXRT) #include @@ -29,16 +25,16 @@ #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #endif // _LIBCPPABI_VERSION -#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include() +#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) #include using namespace __cxxabiv1; #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION) #define HAVE_DEPENDENT_EH_ABI 1 #endif -#elif !defined(__GLIBCXX__) // __has_include() +#elif !defined(__GLIBCXX__) // defined(LIBCXX_BUILDING_LIBCXXABI) static std::terminate_handler __terminate_handler; static std::unexpected_handler __unexpected_handler; -#endif // __has_include() +#endif // defined(LIBCXX_BUILDING_LIBCXXABI) namespace std { diff --git a/contrib/libc++/src/future.cpp b/contrib/libc++/src/future.cpp index 3132b1861af2..e1758f39df3a 100644 --- a/contrib/libc++/src/future.cpp +++ b/contrib/libc++/src/future.cpp @@ -221,10 +221,12 @@ promise::~promise() { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } diff --git a/contrib/libc++/src/support/atomic_support.h b/contrib/libc++/src/include/atomic_support.h similarity index 92% rename from contrib/libc++/src/support/atomic_support.h rename to contrib/libc++/src/include/atomic_support.h index dbf3b9c81ea4..8b719c5f2214 100644 --- a/contrib/libc++/src/support/atomic_support.h +++ b/contrib/libc++/src/include/atomic_support.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===//// +// +// 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 ATOMIC_SUPPORT_H #define ATOMIC_SUPPORT_H diff --git a/contrib/libc++/src/config_elast.h b/contrib/libc++/src/include/config_elast.h similarity index 100% rename from contrib/libc++/src/config_elast.h rename to contrib/libc++/src/include/config_elast.h diff --git a/contrib/libc++/src/ios.cpp b/contrib/libc++/src/ios.cpp index 90972c407d79..23e3ee0ca044 100644 --- a/contrib/libc++/src/ios.cpp +++ b/contrib/libc++/src/ios.cpp @@ -15,7 +15,7 @@ #include "__locale" #include "algorithm" -#include "config_elast.h" +#include "include/config_elast.h" #include "istream" #include "limits" #include "memory" @@ -152,7 +152,7 @@ ios_base::getloc() const } // xalloc -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0); #else int ios_base::__xindex_ = 0; diff --git a/contrib/libc++/src/locale.cpp b/contrib/libc++/src/locale.cpp index bdc73e1d5379..6b04e7881764 100644 --- a/contrib/libc++/src/locale.cpp +++ b/contrib/libc++/src/locale.cpp @@ -812,7 +812,8 @@ 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, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c; @@ -825,7 +826,8 @@ 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 @@ -839,7 +841,8 @@ 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, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c; @@ -852,7 +855,8 @@ 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 @@ -922,7 +926,7 @@ ctype::do_toupper(char_type c) const #elif defined(__NetBSD__) return static_cast(__classic_upper_table()[static_cast(c)]); #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) - return isascii(c) ? + return isascii(c) ? static_cast(__classic_upper_table()[static_cast(c)]) : c; #else return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c; @@ -955,7 +959,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__) return isascii(c) ? static_cast(__classic_lower_table()[static_cast(c)]) : c; #else @@ -1012,7 +1016,7 @@ ctype::do_narrow(const char_type* low, const char_type* high, char dfault, return low; } -#ifdef __EMSCRIPTEN__ +#if defined(__EMSCRIPTEN__) extern "C" const unsigned short ** __ctype_b_loc(); extern "C" const int ** __ctype_tolower_loc(); extern "C" const int ** __ctype_toupper_loc(); @@ -1169,7 +1173,7 @@ ctype::__classic_upper_table() _NOEXCEPT { return *__ctype_toupper_loc(); } -#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__ +#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ // template <> class ctype_byname diff --git a/contrib/libc++/src/memory.cpp b/contrib/libc++/src/memory.cpp index 66fb143c6a62..5b81f26e3dc0 100644 --- a/contrib/libc++/src/memory.cpp +++ b/contrib/libc++/src/memory.cpp @@ -13,7 +13,7 @@ #include "mutex" #include "thread" #endif -#include "support/atomic_support.h" +#include "include/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD @@ -124,7 +124,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT #endif // _LIBCPP_NO_RTTI -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static const std::size_t __sp_mut_count = 16; static pthread_mutex_t mut_back_imp[__sp_mut_count] = @@ -177,7 +177,7 @@ __get_sp_mut(const void* p) return muts[hash()(p) & (__sp_mut_count-1)]; } -#endif // __has_feature(cxx_atomic) && !_LIBCPP_HAS_NO_THREADS +#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) void declare_reachable(void*) diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp index 5f8ba0a08266..127e67a2627e 100644 --- a/contrib/libc++/src/mutex.cpp +++ b/contrib/libc++/src/mutex.cpp @@ -12,7 +12,7 @@ #include "limits" #include "system_error" #include "cassert" -#include "support/atomic_support.h" +#include "include/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS diff --git a/contrib/libc++/src/new.cpp b/contrib/libc++/src/new.cpp index c28fcb5917cf..f4f73d86803d 100644 --- a/contrib/libc++/src/new.cpp +++ b/contrib/libc++/src/new.cpp @@ -13,10 +13,6 @@ #include "new" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - #if defined(__APPLE__) && !defined(LIBCXXRT) #include @@ -27,9 +23,9 @@ #define __new_handler __cxxabiapple::__cxa_new_handler #endif #else // __APPLE__ - #if defined(LIBCXXRT) || __has_include() + #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) #include - #endif // __has_include() + #endif // defined(LIBCXX_BUILDING_LIBCXXABI) #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION @@ -38,7 +34,7 @@ #ifndef __GLIBCXX__ // Implement all new and delete operators as weak definitions -// in this shared library, so that they can be overriden by programs +// in this shared library, so that they can be overridden by programs // that define non-weak copies of the functions. _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS diff --git a/contrib/libc++/src/stdexcept.cpp b/contrib/libc++/src/stdexcept.cpp index aff4b1850d36..0a08bfec27ec 100644 --- a/contrib/libc++/src/stdexcept.cpp +++ b/contrib/libc++/src/stdexcept.cpp @@ -13,12 +13,8 @@ #include "string" #include "system_error" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - /* For _LIBCPPABI_VERSION */ -#if __has_include() || defined(__APPLE_) || defined(LIBCXXRT) +#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT) #include #endif diff --git a/contrib/libc++/src/system_error.cpp b/contrib/libc++/src/system_error.cpp index 18f668f071cd..3023e200aa34 100644 --- a/contrib/libc++/src/system_error.cpp +++ b/contrib/libc++/src/system_error.cpp @@ -12,7 +12,7 @@ #define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" -#include "config_elast.h" +#include "include/config_elast.h" #include "cstring" #include "string" diff --git a/contrib/libc++/src/typeinfo.cpp b/contrib/libc++/src/typeinfo.cpp index b4281209170c..5c0a609b5e5c 100644 --- a/contrib/libc++/src/typeinfo.cpp +++ b/contrib/libc++/src/typeinfo.cpp @@ -8,13 +8,8 @@ //===----------------------------------------------------------------------===// #include -#ifndef __has_include -#define __has_include(inc) 0 -#endif - -#ifdef __APPLE__ -#include -#elif defined(LIBCXXRT) || __has_include() +#if defined(__APPLE__) || defined(LIBCXXRT) || \ + defined(LIBCXX_BUILDING_LIBCXXABI) #include #endif diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index e4d3bdad9c83..984e70bebe87 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -18,6 +18,7 @@ SHLIB_MAJOR= 1 SHLIB_LDSCRIPT= libc++.ldscript SRCS+= algorithm.cpp\ + any.cpp\ bind.cpp\ chrono.cpp\ condition_variable.cpp\ @@ -62,7 +63,7 @@ cxxrt_${_S}: ${_LIBCXXRTDIR}/${_S} .NOMETA .endfor WARNS= 0 -CFLAGS+= -I${HDRDIR} -I${_LIBCXXRTDIR} -nostdlib -DLIBCXXRT +CFLAGS+= -I${HDRDIR} -I${_LIBCXXRTDIR} -nostdinc++ -nostdlib -DLIBCXXRT .if empty(CXXFLAGS:M-std=*) CXXFLAGS+= -std=c++11 .endif @@ -79,6 +80,7 @@ STD_HEADERS= __bit_reference\ __hash_table\ __locale\ __mutex_base\ + __nullptr\ __refstring\ __split_buffer\ __sso_allocator\ @@ -118,15 +120,19 @@ STD_HEADERS= __bit_reference\ cstring\ ctgmath\ ctime\ + ctype.h\ cwchar\ cwctype\ deque\ + errno.h\ exception\ + float.h\ forward_list\ fstream\ functional\ future\ initializer_list\ + inttypes.h\ iomanip\ ios\ iosfwd\ @@ -137,6 +143,7 @@ STD_HEADERS= __bit_reference\ list\ locale\ map\ + math.h\ memory\ mutex\ new\ @@ -148,10 +155,14 @@ STD_HEADERS= __bit_reference\ regex\ scoped_allocator\ set\ + setjmp.h\ shared_mutex\ sstream\ stack\ + stddef.h\ stdexcept\ + stdio.h\ + stdlib.h\ streambuf\ string\ strstream\ @@ -166,7 +177,9 @@ STD_HEADERS= __bit_reference\ unordered_set\ utility\ valarray\ - vector + vector\ + wchar.h\ + wctype.h RT_HEADERS= cxxabi.h\ unwind.h\ unwind-arm.h\ @@ -183,8 +196,10 @@ STDDIR= ${CXXINCLUDEDIR} EXP_HEADERS= __config\ algorithm\ + any\ chrono\ dynarray\ + functional\ optional\ ratio\ string_view\