diff options
Diffstat (limited to 'contrib/libc++/include/string')
-rw-r--r-- | contrib/libc++/include/string | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index fe42bbf1d998..6be21955b146 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -220,8 +220,8 @@ public: basic_string substr(size_type pos = 0, size_type n = npos) const; void swap(basic_string& str) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable<allocator_type>::value) + noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || + allocator_traits<allocator_type>::is_always_equal::value); // C++17 const value_type* c_str() const noexcept; const value_type* data() const noexcept; @@ -636,19 +636,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char> {return (unsigned char)__c1 < (unsigned char)__c2;} static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return memcmp(__s1, __s2, __n);} + {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);} static inline size_t length(const char_type* __s) {return strlen(__s);} static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)memchr(__s, to_int_type(__a), __n);} + {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);} static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memmove(__s1, __s2, __n);} + {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return (char_type*)memcpy(__s1, __s2, __n); + return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); } static inline char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)memset(__s, to_int_type(__a), __n);} + {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -681,20 +681,20 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t> {return __c1 < __c2;} static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return wmemcmp(__s1, __s2, __n);} + {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);} static inline size_t length(const char_type* __s) {return wcslen(__s);} static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)wmemchr(__s, __a, __n);} + {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);} static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemmove(__s1, __s2, __n);} + {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return (char_type*)wmemcpy(__s1, __s2, __n); + return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n); } static inline char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)wmemset(__s, __a, __n);} + {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);} static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -1322,13 +1322,26 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); - _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a); + + _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); +#else + _NOEXCEPT; +#endif + basic_string(const basic_string& __str); basic_string(const basic_string& __str, const allocator_type& __a); + #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str) +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); +#else + _NOEXCEPT; +#endif + _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1591,8 +1604,12 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(basic_string& __str) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<allocator_type>::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value); +#endif _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const _NOEXCEPT {return data();} @@ -1855,24 +1872,6 @@ private: _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<allocator_type>::value) - {__swap_alloc(__x, __y, integral_constant<bool, - __alloc_traits::propagate_on_container_swap::value>());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type&, allocator_type&, false_type) _NOEXCEPT - {} - _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); @@ -2070,7 +2069,11 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) +#else + _NOEXCEPT +#endif : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); @@ -3349,8 +3352,12 @@ template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<allocator_type>::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value) +#endif { #if _LIBCPP_DEBUG_LEVEL >= 2 if (!__is_long()) @@ -3360,7 +3367,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) __get_db()->swap(this, &__str); #endif _VSTD::swap(__r_.first(), __str.__r_.first()); - __swap_alloc(__alloc(), __str.__alloc()); + __swap_allocator(__alloc(), __str.__alloc()); } // find |