34 #ifndef _GLIBCXX_STRING_VIEW_TCC
35 #define _GLIBCXX_STRING_VIEW_TCC 1
37 #pragma GCC system_header
39 #if __cplusplus >= 201703L
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template<
typename _CharT,
typename _Traits>
46 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
47 basic_string_view<_CharT, _Traits>::
48 find(
const _CharT* __str, size_type __pos, size_type __n)
const noexcept
50 __glibcxx_requires_string_len(__str, __n);
53 return __pos <= _M_len ? __pos : npos;
57 const _CharT __elem0 = __str[0];
58 const _CharT* __first = _M_str + __pos;
59 const _CharT*
const __last = _M_str + _M_len;
60 size_type __len = _M_len - __pos;
65 __first = traits_type::find(__first, __len - __n + 1, __elem0);
71 if (traits_type::compare(__first, __str, __n) == 0)
72 return __first - _M_str;
73 __len = __last - ++__first;
78 template<
typename _CharT,
typename _Traits>
79 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
80 basic_string_view<_CharT, _Traits>::
81 find(_CharT __c, size_type __pos)
const noexcept
83 size_type __ret = npos;
84 if (__pos < this->_M_len)
86 const size_type __n = this->_M_len - __pos;
87 const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
89 __ret = __p - this->_M_str;
94 template<
typename _CharT,
typename _Traits>
95 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
96 basic_string_view<_CharT, _Traits>::
97 rfind(
const _CharT* __str, size_type __pos, size_type __n)
const noexcept
99 __glibcxx_requires_string_len(__str, __n);
101 if (__n <= this->_M_len)
103 __pos =
std::min(size_type(this->_M_len - __n), __pos);
106 if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
114 template<
typename _CharT,
typename _Traits>
115 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
116 basic_string_view<_CharT, _Traits>::
117 rfind(_CharT __c, size_type __pos)
const noexcept
119 size_type __size = this->_M_len;
122 if (--__size > __pos)
124 for (++__size; __size-- > 0; )
125 if (traits_type::eq(this->_M_str[__size], __c))
131 template<
typename _CharT,
typename _Traits>
132 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
133 basic_string_view<_CharT, _Traits>::
134 find_first_of(
const _CharT* __str, size_type __pos,
135 size_type __n)
const noexcept
137 __glibcxx_requires_string_len(__str, __n);
138 for (; __n && __pos < this->_M_len; ++__pos)
140 const _CharT* __p = traits_type::find(__str, __n,
141 this->_M_str[__pos]);
148 template<
typename _CharT,
typename _Traits>
149 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
150 basic_string_view<_CharT, _Traits>::
151 find_last_of(
const _CharT* __str, size_type __pos,
152 size_type __n)
const noexcept
154 __glibcxx_requires_string_len(__str, __n);
155 size_type __size = this->
size();
158 if (--__size > __pos)
162 if (traits_type::find(__str, __n, this->_M_str[__size]))
165 while (__size-- != 0);
170 template<
typename _CharT,
typename _Traits>
171 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
172 basic_string_view<_CharT, _Traits>::
173 find_first_not_of(
const _CharT* __str, size_type __pos,
174 size_type __n)
const noexcept
176 __glibcxx_requires_string_len(__str, __n);
177 for (; __pos < this->_M_len; ++__pos)
178 if (!traits_type::find(__str, __n, this->_M_str[__pos]))
183 template<
typename _CharT,
typename _Traits>
184 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
185 basic_string_view<_CharT, _Traits>::
186 find_first_not_of(_CharT __c, size_type __pos)
const noexcept
188 for (; __pos < this->_M_len; ++__pos)
189 if (!traits_type::eq(this->_M_str[__pos], __c))
194 template<
typename _CharT,
typename _Traits>
195 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
196 basic_string_view<_CharT, _Traits>::
197 find_last_not_of(
const _CharT* __str, size_type __pos,
198 size_type __n)
const noexcept
200 __glibcxx_requires_string_len(__str, __n);
201 size_type __size = this->_M_len;
204 if (--__size > __pos)
208 if (!traits_type::find(__str, __n, this->_M_str[__size]))
216 template<
typename _CharT,
typename _Traits>
217 constexpr
typename basic_string_view<_CharT, _Traits>::size_type
218 basic_string_view<_CharT, _Traits>::
219 find_last_not_of(_CharT __c, size_type __pos)
const noexcept
221 size_type __size = this->_M_len;
224 if (--__size > __pos)
228 if (!traits_type::eq(this->_M_str[__size], __c))
236 _GLIBCXX_END_NAMESPACE_VERSION
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.