-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++][NFC] Inline the simple observer functions into the basic_string definition #126061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesHaving them defined ouf-of-line results in a significant amount of boilerplate without improving readability, since they're just one or two lines long anyways. As a drive-by, add comments between the declarations to make them easier to distinguish. Patch is 33.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126061.diff 1 Files Affected:
diff --git a/libcxx/include/string b/libcxx/include/string
index b7f2d122694639..af3ba578bd870b 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<allocator_type>);
# 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<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(
+ data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(
+ data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ data(), size(), __str.data(), __pos, __str.size());
+ }
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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<value_type, size_type, traits_type, npos>(
+ 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<value_type, size_type, traits_type, npos>(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 <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int
@@ -1818,25 +1942,46 @@ public:
template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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 <class _Tp,
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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 <class _CharT, class _Traits, class _Allocator>
-_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<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-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<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::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<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-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<value_type, size_type, traits_type, npos>(
- data(), size(), __s, __pos, traits_type::length(__s));
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-_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<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
-}
-
-// rfind
-
-template <class _CharT, class _Traits, class _Allocator>
-_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<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-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<value_type, size_type, traits_type, ...
[truncated]
|
…ing definition (llvm#126061) Having them defined ouf-of-line results in a significant amount of boilerplate without improving readability, since they're just one or two lines long anyways. As a drive-by, add comments between the declarations to make them easier to distinguish.
Having them defined ouf-of-line results in a significant amount of boilerplate without improving readability, since they're just one or two lines long anyways.
As a drive-by, add comments between the declarations to make them easier to distinguish.