diff --git a/libcxx/include/string b/libcxx/include/string index b7f2d12269463..af3ba578bd870 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1716,6 +1716,9 @@ public: _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v); # endif + // [string.ops] + // ------------ + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { return std::__to_address(__get_pointer()); @@ -1730,87 +1733,208 @@ public: return __alloc_; } + // find + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { + return std::__str_find(data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_find(data(), size(), __sv.data(), __pos, __sv.size()); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); + return std::__str_find(data(), size(), __s, __pos, __n); + } - _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; + find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); + return std::__str_find( + data(), size(), __s, __pos, traits_type::length(__s)); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT { + return std::__str_find(data(), size(), __c, __pos); + } + + // rfind _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { + return std::__str_rfind( + data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_rfind(data(), size(), __sv.data(), __pos, __sv.size()); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); + return std::__str_rfind(data(), size(), __s, __pos, __n); + } - _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; + rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); + return std::__str_rfind( + data(), size(), __s, __pos, traits_type::length(__s)); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT { + return std::__str_rfind(data(), size(), __c, __pos); + } + + // find_first_of _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { + return std::__str_find_first_of( + data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_find_first_of( + data(), size(), __sv.data(), __pos, __sv.size()); + } _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); + return std::__str_find_first_of(data(), size(), __s, __pos, __n); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); + return std::__str_find_first_of( + data(), size(), __s, __pos, traits_type::length(__s)); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; + find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { + return find(__c, __pos); + } + + // find_last_of _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { + return std::__str_find_last_of( + data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_find_last_of( + data(), size(), __sv.data(), __pos, __sv.size()); + } _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); + return std::__str_find_last_of(data(), size(), __s, __pos, __n); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); + return std::__str_find_last_of( + data(), size(), __s, __pos, traits_type::length(__s)); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; + find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { + return rfind(__c, __pos); + } + + // find_first_not_of _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { + return std::__str_find_first_not_of( + data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_find_first_not_of( + data(), size(), __sv.data(), __pos, __sv.size()); + } _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); + return std::__str_find_first_not_of(data(), size(), __s, __pos, __n); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); + return std::__str_find_first_not_of( + data(), size(), __s, __pos, traits_type::length(__s)); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; + find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { + return std::__str_find_first_not_of(data(), size(), __c, __pos); + } + + // find_last_not_of _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { + return std::__str_find_last_not_of( + data(), size(), __str.data(), __pos, __str.size()); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { + __self_view __sv = __t; + return std::__str_find_last_not_of( + data(), size(), __sv.data(), __pos, __sv.size()); + } _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); + return std::__str_find_last_not_of(data(), size(), __s, __pos, __n); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); + return std::__str_find_last_not_of( + data(), size(), __s, __pos, traits_type::length(__s)); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type - find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; + find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { + return std::__str_find_last_not_of(data(), size(), __c, __pos); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT; + // compare + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT { + return compare(__self_view(__str)); + } template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int @@ -1818,25 +1942,46 @@ public: template ::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int - compare(size_type __pos1, size_type __n1, const _Tp& __t) const; + compare(size_type __pos1, size_type __n1, const _Tp& __t) const { + __self_view __sv = __t; + return compare(__pos1, __n1, __sv.data(), __sv.size()); + } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int - compare(size_type __pos1, size_type __n1, const basic_string& __str) const; + compare(size_type __pos1, size_type __n1, const basic_string& __str) const { + return compare(__pos1, __n1, __str.data(), __str.size()); + } + _LIBCPP_CONSTEXPR_SINCE_CXX20 int - compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const; + compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const { + return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); + } template ::value && !__is_same_uncvref<_Tp, basic_string>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int - compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const; + compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const { + __self_view __sv = __t; + return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); + return compare(0, npos, __s, traits_type::length(__s)); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const { + _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); + return compare(__pos1, __n1, __s, traits_type::length(__s)); + } - _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; + // starts_with + # if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); @@ -1850,6 +1995,8 @@ public: return starts_with(__self_view(__s)); } + // ends_with + constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); } @@ -1863,6 +2010,8 @@ public: } # endif + // contains + # if _LIBCPP_STD_VER >= 23 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); @@ -3481,243 +3630,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat __str.__annotate_new(__str.__get_short_size()); } -// find - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); - return std::__str_find(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_find(data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_find(data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); - return std::__str_find( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { - return std::__str_find(data(), size(), __c, __pos); -} - -// rfind - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind( - const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); - return std::__str_rfind(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_rfind(data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_rfind(data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); - return std::__str_rfind( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { - return std::__str_rfind(data(), size(), __c, __pos); -} - -// find_first_of - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of( - const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); - return std::__str_find_first_of(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_find_first_of( - data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_find_first_of( - data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); - return std::__str_find_first_of( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT { - return find(__c, __pos); -} - -// find_last_of - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of( - const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); - return std::__str_find_last_of(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_find_last_of( - data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_find_last_of( - data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); - return std::__str_find_last_of( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT { - return rfind(__c, __pos); -} - -// find_first_not_of - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( - const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); - return std::__str_find_first_not_of(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( - const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_find_first_not_of( - data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_find_first_not_of( - data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); - return std::__str_find_first_not_of( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - return std::__str_find_first_not_of(data(), size(), __c, __pos); -} - -// find_last_not_of - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( - const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); - return std::__str_find_last_not_of(data(), size(), __s, __pos, __n); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( - const basic_string& __str, size_type __pos) const _NOEXCEPT { - return std::__str_find_last_not_of( - data(), size(), __str.data(), __pos, __str.size()); -} - -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { - __self_view __sv = __t; - return std::__str_find_last_not_of( - data(), size(), __sv.data(), __pos, __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); - return std::__str_find_last_not_of( - data(), size(), __s, __pos, traits_type::length(__s)); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - return std::__str_find_last_not_of(data(), size(), __c, __pos); -} - // compare template @@ -3736,12 +3648,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::com return 0; } -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { - return compare(__self_view(__str)); -} - template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const { @@ -3760,51 +3666,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocato return __r; } -template -template ::value, int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const { - __self_view __sv = __t; - return compare(__pos1, __n1, __sv.data(), __sv.size()); -} - -template -inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const { - return compare(__pos1, __n1, __str.data(), __str.size()); -} - -template -template ::value && - !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - int> > -_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( - size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const { - __self_view __sv = __t; - return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); -} - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( - size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const { - return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); -} - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); - return compare(0, npos, __s, traits_type::length(__s)); -} - -template -_LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { - _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); - return compare(__pos1, __n1, __s, traits_type::length(__s)); -} - // __invariants template