diff options
author | danlark <[email protected]> | 2022-02-10 16:46:08 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:08 +0300 |
commit | 3426a9bc7f169ae9da54cef557ad2a33f6e8eee0 (patch) | |
tree | 26154e1e9990f1bb4525d3e3fb5b6dac2c2c1da2 /contrib/libs/cxxsupp/libcxx/include/__string | |
parent | cb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__string')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__string | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__string b/contrib/libs/cxxsupp/libcxx/include/__string index 7074a735386..76ecaeec1f2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__string +++ b/contrib/libs/cxxsupp/libcxx/include/__string @@ -1,9 +1,9 @@ // -*- C++ -*- //===-------------------------- __string ----------------------------------===// // -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -348,13 +348,13 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> static _LIBCPP_CONSTEXPR_AFTER_CXX14 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; #ifdef _LIBCPP_COMPILER_MSVC - static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT - { - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; - } + static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT + { + size_t __len = 0; + for (; !eq(*__s, char_type(0)); ++__s) + ++__len; + return __len; + } #else static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} @@ -548,7 +548,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __ if (__n == 0) return nullptr; #if __has_feature(cxx_constexpr_string_builtins) && !defined(__CUDACC__) - return __builtin_wmemchr(__s, __a, __n); + return __builtin_wmemchr(__s, __a, __n); #elif _LIBCPP_STD_VER <= 14 return _VSTD::wmemchr(__s, __a, __n); #else @@ -583,31 +583,31 @@ inline size_t __char_traits_length_checked(const typename _Traits::char_type* __ #endif #ifndef _LIBCPP_HAS_NO_CHAR8_T - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> -{ - typedef char8_t char_type; - typedef unsigned int int_type; - typedef streamoff off_type; - typedef u8streampos pos_type; - typedef mbstate_t state_type; - - static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept - {__c1 = __c2;} - static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept - {return __c1 < __c2;} - - static constexpr - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - - static constexpr - size_t length(const char_type* __s) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY static constexpr - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; + +template <> +struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> +{ + typedef char8_t char_type; + typedef unsigned int int_type; + typedef streamoff off_type; + typedef u8streampos pos_type; + typedef mbstate_t state_type; + + static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept + {__c1 = __c2;} + static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept + {return __c1 == __c2;} + static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept + {return __c1 < __c2;} + + static constexpr + int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; + + static constexpr + size_t length(const char_type* __s) _NOEXCEPT; + + _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 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT @@ -635,64 +635,64 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> ? _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 - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline constexpr char_type to_char_type(int_type __c) noexcept - {return char_type(__c);} - static inline constexpr int_type to_int_type(char_type __c) noexcept - {return int_type(__c);} - static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr int_type eof() noexcept - {return int_type(EOF);} -}; - -// TODO use '__builtin_strlen' if it ever supports char8_t ?? -inline constexpr -size_t -char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline constexpr -int -char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_memcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -// TODO use '__builtin_char_memchr' if it ever supports char8_t ?? -inline constexpr -const char8_t* -char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } + + static inline constexpr int_type not_eof(int_type __c) noexcept + {return eq_int_type(__c, eof()) ? ~eof() : __c;} + static inline constexpr char_type to_char_type(int_type __c) noexcept + {return char_type(__c);} + static inline constexpr int_type to_int_type(char_type __c) noexcept + {return int_type(__c);} + static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept + {return __c1 == __c2;} + static inline constexpr int_type eof() noexcept + {return int_type(EOF);} +}; + +// TODO use '__builtin_strlen' if it ever supports char8_t ?? +inline constexpr +size_t +char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT +{ + size_t __len = 0; + for (; !eq(*__s, char_type(0)); ++__s) + ++__len; + return __len; +} + +inline constexpr +int +char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT +{ +#if __has_feature(cxx_constexpr_string_builtins) + return __builtin_memcmp(__s1, __s2, __n); +#else + for (; __n; --__n, ++__s1, ++__s2) + { + if (lt(*__s1, *__s2)) + return -1; + if (lt(*__s2, *__s1)) + return 1; + } + return 0; +#endif +} + +// TODO use '__builtin_char_memchr' if it ever supports char8_t ?? +inline constexpr +const char8_t* +char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT +{ + for (; __n; --__n) + { + if (eq(*__s, __a)) + return __s; + ++__s; + } return nullptr; -} - +} + #endif // #_LIBCPP_HAS_NO_CHAR8_T - + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> |