diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__string')
-rw-r--r-- | contrib/llvm-project/libcxx/include/__string | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/contrib/llvm-project/libcxx/include/__string b/contrib/llvm-project/libcxx/include/__string index 9060bf98ad89..d8b672e4c1be 100644 --- a/contrib/llvm-project/libcxx/include/__string +++ b/contrib/llvm-project/libcxx/include/__string @@ -55,7 +55,9 @@ template <> struct char_traits<char8_t>; // c++20 #include <__config> #include <algorithm> // for search and min -#include <cstdio> // For EOF. +#include <cstdio> // for EOF +#include <cstring> // for memcpy +#include <cwchar> // for wmemcpy #include <memory> // for __murmur2_or_cityhash #include <__debug> @@ -92,7 +94,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, std::allocator<_CharType> const&)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ @@ -108,7 +110,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ @@ -158,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ @@ -268,7 +270,7 @@ char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a return __s; ++__s; } - return 0; + return nullptr; } template <class _CharT> @@ -318,7 +320,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) // constexpr versions of move/copy/assign. template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED +static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT { if (__n == 0) return __s1; @@ -331,7 +333,7 @@ _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT } template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED +static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT { _VSTD::copy_n(__s2, __n, __s1); @@ -339,7 +341,7 @@ _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT } template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED +static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT { _VSTD::fill_n(__s, __n, __a); @@ -370,27 +372,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} static _LIBCPP_CONSTEXPR_AFTER_CXX14 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); } static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -414,7 +416,7 @@ char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t #if __has_feature(cxx_constexpr_string_builtins) return __builtin_memcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 - return memcmp(__s1, __s2, __n); + return _VSTD::memcmp(__s1, __s2, __n); #else for (; __n; --__n, ++__s1, ++__s2) { @@ -436,7 +438,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) #if __has_feature(cxx_constexpr_string_builtins) return __builtin_char_memchr(__s, to_int_type(__a), __n); #elif _LIBCPP_STD_VER <= 14 - return (const char_type*) memchr(__s, to_int_type(__a), __n); + return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n); #else for (; __n; --__n) { @@ -473,27 +475,27 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> size_t length(const char_type* __s) _NOEXCEPT; static _LIBCPP_CONSTEXPR_AFTER_CXX14 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : wmemmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n); } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : wmemset(__s, __a, __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n); } static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -516,7 +518,7 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 - return wmemcmp(__s1, __s2, __n); + return _VSTD::wmemcmp(__s1, __s2, __n); #else for (; __n; --__n, ++__s1, ++__s2) { @@ -548,7 +550,7 @@ char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wcslen(__s); #elif _LIBCPP_STD_VER <= 14 - return wcslen(__s); + return _VSTD::wcslen(__s); #else size_t __len = 0; for (; !eq(*__s, char_type(0)); ++__s) @@ -566,7 +568,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemchr(__s, __a, __n); #elif _LIBCPP_STD_VER <= 14 - return wmemchr(__s, __a, __n); + return _VSTD::wmemchr(__s, __a, __n); #else for (; __n; --__n) { @@ -606,29 +608,29 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> _LIBCPP_INLINE_VISIBILITY static constexpr const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); } - static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); } - static _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED + static _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); } static inline constexpr int_type not_eof(int_type __c) noexcept @@ -683,7 +685,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __ return __s; ++__s; } - return 0; + return nullptr; } #endif // #_LIBCPP_NO_HAS_CHAR8_T @@ -765,7 +767,7 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _ return __s; ++__s; } - return 0; + return nullptr; } inline _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -885,7 +887,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _ return __s; ++__s; } - return 0; + return nullptr; } inline _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -943,7 +945,7 @@ __str_find(const _CharT *__p, _SizeT __sz, if (__pos >= __sz) return __npos; const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); - if (__r == 0) + if (__r == nullptr) return __npos; return static_cast<_SizeT>(__r - __p); } @@ -972,7 +974,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1, // Find __f2 the first byte matching in __first1. __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); - if (__first1 == 0) + if (__first1 == nullptr) return __last1; // It is faster to compare from the first byte of __first1 even if we @@ -1095,7 +1097,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz, { const _CharT* __pe = __p + __sz; for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) - if (_Traits::find(__s, __n, *__ps) == 0) + if (_Traits::find(__s, __n, *__ps) == nullptr) return static_cast<_SizeT>(__ps - __p); } return __npos; @@ -1129,7 +1131,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz, else __pos = __sz; for (const _CharT* __ps = __p + __pos; __ps != __p;) - if (_Traits::find(__s, __n, *--__ps) == 0) + if (_Traits::find(__s, __n, *--__ps) == nullptr) return static_cast<_SizeT>(__ps - __p); return __npos; } |