34#pragma GCC system_header
41namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template<
typename _CharT,
typename _Traits,
typename _Alloc,
46 template <
typename,
typename,
typename>
class _Base>
47 const typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
50 template<
typename _CharT,
typename _Traits,
typename _Alloc,
51 template <
typename,
typename,
typename>
class _Base>
54 resize(size_type __n, _CharT __c)
56 const size_type __size = this->
size();
58 this->
append(__n - __size, __c);
59 else if (__n < __size)
60 this->_M_erase(__n, __size - __n);
63 template<
typename _CharT,
typename _Traits,
typename _Alloc,
64 template <
typename,
typename,
typename>
class _Base>
67 _M_append(
const _CharT* __s, size_type __n)
69 const size_type __len = __n + this->size();
71 if (__len <= this->capacity() && !this->_M_is_shared())
74 this->_S_copy(this->_M_data() + this->size(), __s, __n);
77 this->_M_mutate(this->size(), size_type(0), __s, __n);
79 this->_M_set_length(__len);
83 template<
typename _CharT,
typename _Traits,
typename _Alloc,
84 template <
typename,
typename,
typename>
class _Base>
85 template<
typename _InputIterator>
89 _InputIterator __k1, _InputIterator __k2,
93 const size_type __n1 = __i2 - __i1;
94 return _M_replace(__i1 - _M_ibegin(), __n1, __s._M_data(),
98 template<
typename _CharT,
typename _Traits,
typename _Alloc,
99 template <
typename,
typename,
typename>
class _Base>
105 _M_check_length(__n1, __n2,
"__versa_string::_M_replace_aux");
107 const size_type __old_size = this->
size();
108 const size_type __new_size = __old_size + __n2 - __n1;
110 if (__new_size <= this->capacity() && !this->_M_is_shared())
112 _CharT* __p = this->_M_data() + __pos1;
114 const size_type __how_much = __old_size - __pos1 - __n1;
115 if (__how_much && __n1 != __n2)
116 this->_S_move(__p + __n2, __p + __n1, __how_much);
119 this->_M_mutate(__pos1, __n1, 0, __n2);
122 this->_S_assign(this->_M_data() + __pos1, __n2, __c);
124 this->_M_set_length(__new_size);
128 template<
typename _CharT,
typename _Traits,
typename _Alloc,
129 template <
typename,
typename,
typename>
class _Base>
132 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
133 const size_type __len2)
135 _M_check_length(__len1, __len2,
"__versa_string::_M_replace");
137 const size_type __old_size = this->
size();
138 const size_type __new_size = __old_size + __len2 - __len1;
140 if (__new_size <= this->capacity() && !this->_M_is_shared())
142 _CharT* __p = this->_M_data() + __pos;
144 const size_type __how_much = __old_size - __pos - __len1;
145 if (_M_disjunct(__s))
147 if (__how_much && __len1 != __len2)
148 this->_S_move(__p + __len2, __p + __len1, __how_much);
150 this->_S_copy(__p, __s, __len2);
155 if (__len2 && __len2 <= __len1)
156 this->_S_move(__p, __s, __len2);
157 if (__how_much && __len1 != __len2)
158 this->_S_move(__p + __len2, __p + __len1, __how_much);
161 if (__s + __len2 <= __p + __len1)
162 this->_S_move(__p, __s, __len2);
163 else if (__s >= __p + __len1)
164 this->_S_copy(__p, __s + __len2 - __len1, __len2);
167 const size_type __nleft = (__p + __len1) - __s;
168 this->_S_move(__p, __s, __nleft);
169 this->_S_copy(__p + __nleft, __p + __len2,
176 this->_M_mutate(__pos, __len1, __s, __len2);
178 this->_M_set_length(__new_size);
182 template<
typename _CharT,
typename _Traits,
typename _Alloc,
183 template <
typename,
typename,
typename>
class _Base>
195 template<
typename _CharT,
typename _Traits,
typename _Alloc,
196 template <
typename,
typename,
typename>
class _Base>
197 __versa_string<_CharT, _Traits, _Alloc, _Base>
198 operator+(
const _CharT* __lhs,
201 __glibcxx_requires_string(__lhs);
203 typedef typename __string_type::size_type __size_type;
204 const __size_type __len = _Traits::length(__lhs);
206 __str.reserve(__len + __rhs.
size());
207 __str.append(__lhs, __len);
212 template<
typename _CharT,
typename _Traits,
typename _Alloc,
213 template <
typename,
typename,
typename>
class _Base>
214 __versa_string<_CharT, _Traits, _Alloc, _Base>
215 operator+(_CharT __lhs,
225 template<
typename _CharT,
typename _Traits,
typename _Alloc,
226 template <
typename,
typename,
typename>
class _Base>
227 __versa_string<_CharT, _Traits, _Alloc, _Base>
231 __glibcxx_requires_string(__rhs);
233 typedef typename __string_type::size_type __size_type;
234 const __size_type __len = _Traits::length(__rhs);
236 __str.reserve(__lhs.
size() + __len);
238 __str.append(__rhs, __len);
242 template<
typename _CharT,
typename _Traits,
typename _Alloc,
243 template <
typename,
typename,
typename>
class _Base>
244 __versa_string<_CharT, _Traits, _Alloc, _Base>
255 template<
typename _CharT,
typename _Traits,
typename _Alloc,
256 template <
typename,
typename,
typename>
class _Base>
257 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
259 copy(_CharT* __s, size_type __n, size_type __pos)
const
261 _M_check(__pos,
"__versa_string::copy");
262 __n = _M_limit(__pos, __n);
263 __glibcxx_requires_string_len(__s, __n);
265 this->_S_copy(__s, this->_M_data() + __pos, __n);
270 template<
typename _CharT,
typename _Traits,
typename _Alloc,
271 template <
typename,
typename,
typename>
class _Base>
272 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
274 find(
const _CharT* __s, size_type __pos, size_type __n)
const
276 __glibcxx_requires_string_len(__s, __n);
277 const size_type __size = this->
size();
278 const _CharT* __data = this->_M_data();
281 return __pos <= __size ? __pos :
npos;
285 for (; __pos <= __size - __n; ++__pos)
286 if (traits_type::eq(__data[__pos], __s[0])
287 && traits_type::compare(__data + __pos + 1,
288 __s + 1, __n - 1) == 0)
294 template<
typename _CharT,
typename _Traits,
typename _Alloc,
295 template <
typename,
typename,
typename>
class _Base>
296 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
298 find(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
300 size_type __ret =
npos;
301 const size_type __size = this->
size();
304 const _CharT* __data = this->_M_data();
305 const size_type __n = __size - __pos;
306 const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
308 __ret = __p - __data;
313 template<
typename _CharT,
typename _Traits,
typename _Alloc,
314 template <
typename,
typename,
typename>
class _Base>
315 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
317 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
319 __glibcxx_requires_string_len(__s, __n);
320 const size_type __size = this->
size();
323 __pos =
std::min(size_type(__size - __n), __pos);
324 const _CharT* __data = this->_M_data();
327 if (traits_type::compare(__data + __pos, __s, __n) == 0)
335 template<
typename _CharT,
typename _Traits,
typename _Alloc,
336 template <
typename,
typename,
typename>
class _Base>
337 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
339 rfind(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
341 size_type __size = this->
size();
344 if (--__size > __pos)
346 for (++__size; __size-- > 0; )
347 if (traits_type::eq(this->_M_data()[__size], __c))
353 template<
typename _CharT,
typename _Traits,
typename _Alloc,
354 template <
typename,
typename,
typename>
class _Base>
355 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
357 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
359 __glibcxx_requires_string_len(__s, __n);
360 for (; __n && __pos < this->
size(); ++__pos)
362 const _CharT* __p = traits_type::find(__s, __n,
363 this->_M_data()[__pos]);
370 template<
typename _CharT,
typename _Traits,
typename _Alloc,
371 template <
typename,
typename,
typename>
class _Base>
372 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
374 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
376 __glibcxx_requires_string_len(__s, __n);
377 size_type __size = this->
size();
380 if (--__size > __pos)
384 if (traits_type::find(__s, __n, this->_M_data()[__size]))
387 while (__size-- != 0);
392 template<
typename _CharT,
typename _Traits,
typename _Alloc,
393 template <
typename,
typename,
typename>
class _Base>
394 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
398 __glibcxx_requires_string_len(__s, __n);
399 for (; __pos < this->
size(); ++__pos)
400 if (!traits_type::find(__s, __n, this->_M_data()[__pos]))
405 template<
typename _CharT,
typename _Traits,
typename _Alloc,
406 template <
typename,
typename,
typename>
class _Base>
407 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
411 for (; __pos < this->
size(); ++__pos)
412 if (!traits_type::eq(this->_M_data()[__pos], __c))
417 template<
typename _CharT,
typename _Traits,
typename _Alloc,
418 template <
typename,
typename,
typename>
class _Base>
419 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
423 __glibcxx_requires_string_len(__s, __n);
424 size_type __size = this->
size();
427 if (--__size > __pos)
431 if (!traits_type::find(__s, __n, this->_M_data()[__size]))
439 template<
typename _CharT,
typename _Traits,
typename _Alloc,
440 template <
typename,
typename,
typename>
class _Base>
441 typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
445 size_type __size = this->
size();
448 if (--__size > __pos)
452 if (!traits_type::eq(this->_M_data()[__size], __c))
460 template<
typename _CharT,
typename _Traits,
typename _Alloc,
461 template <
typename,
typename,
typename>
class _Base>
466 _M_check(__pos,
"__versa_string::compare");
467 __n = _M_limit(__pos, __n);
468 const size_type __osize = __str.
size();
469 const size_type __len =
std::min(__n, __osize);
470 int __r = traits_type::compare(this->_M_data() + __pos,
471 __str.
data(), __len);
473 __r = this->_S_compare(__n, __osize);
477 template<
typename _CharT,
typename _Traits,
typename _Alloc,
478 template <
typename,
typename,
typename>
class _Base>
482 size_type __pos2, size_type __n2)
const
484 _M_check(__pos1,
"__versa_string::compare");
485 __str._M_check(__pos2,
"__versa_string::compare");
486 __n1 = _M_limit(__pos1, __n1);
487 __n2 = __str._M_limit(__pos2, __n2);
488 const size_type __len =
std::min(__n1, __n2);
489 int __r = traits_type::compare(this->_M_data() + __pos1,
490 __str.
data() + __pos2, __len);
492 __r = this->_S_compare(__n1, __n2);
496 template<
typename _CharT,
typename _Traits,
typename _Alloc,
497 template <
typename,
typename,
typename>
class _Base>
500 compare(
const _CharT* __s)
const
502 __glibcxx_requires_string(__s);
503 const size_type __size = this->
size();
504 const size_type __osize = traits_type::length(__s);
505 const size_type __len =
std::min(__size, __osize);
506 int __r = traits_type::compare(this->_M_data(), __s, __len);
508 __r = this->_S_compare(__size, __osize);
512 template<
typename _CharT,
typename _Traits,
typename _Alloc,
513 template <
typename,
typename,
typename>
class _Base>
515 __versa_string <_CharT, _Traits, _Alloc, _Base>::
516 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
518 __glibcxx_requires_string(__s);
519 _M_check(__pos,
"__versa_string::compare");
520 __n1 = _M_limit(__pos, __n1);
521 const size_type __osize = traits_type::length(__s);
522 const size_type __len =
std::min(__n1, __osize);
523 int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
525 __r = this->_S_compare(__n1, __osize);
529 template<
typename _CharT,
typename _Traits,
typename _Alloc,
530 template <
typename,
typename,
typename>
class _Base>
532 __versa_string <_CharT, _Traits, _Alloc, _Base>::
533 compare(size_type __pos, size_type __n1,
const _CharT* __s,
534 size_type __n2)
const
536 __glibcxx_requires_string_len(__s, __n2);
537 _M_check(__pos,
"__versa_string::compare");
538 __n1 = _M_limit(__pos, __n1);
539 const size_type __len =
std::min(__n1, __n2);
540 int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
542 __r = this->_S_compare(__n1, __n2);
546_GLIBCXX_END_NAMESPACE_VERSION
549namespace std _GLIBCXX_VISIBILITY(default)
551_GLIBCXX_BEGIN_NAMESPACE_VERSION
553 template<
typename _CharT,
typename _Traits,
typename _Alloc,
554 template <
typename,
typename,
typename>
class _Base>
555 basic_istream<_CharT, _Traits>&
558 _Alloc, _Base>& __str)
561 typedef typename __istream_type::ios_base __ios_base;
564 typedef typename __istream_type::int_type __int_type;
565 typedef typename __string_type::size_type __size_type;
567 typedef typename __ctype_type::ctype_base __ctype_base;
569 __size_type __extracted = 0;
570 typename __ios_base::iostate __err = __ios_base::goodbit;
571 typename __istream_type::sentry __cerb(__in,
false);
579 __size_type __len = 0;
581 const __size_type __n = __w > 0 ?
static_cast<__size_type
>(__w)
584 const __int_type __eof = _Traits::eof();
585 __int_type __c = __in.
rdbuf()->sgetc();
587 while (__extracted < __n
588 && !_Traits::eq_int_type(__c, __eof)
589 && !__ct.is(__ctype_base::space,
590 _Traits::to_char_type(__c)))
592 if (__len ==
sizeof(__buf) /
sizeof(_CharT))
594 __str.append(__buf,
sizeof(__buf) /
sizeof(_CharT));
597 __buf[__len++] = _Traits::to_char_type(__c);
599 __c = __in.
rdbuf()->snextc();
601 __str.append(__buf, __len);
603 if (_Traits::eq_int_type(__c, __eof))
604 __err |= __ios_base::eofbit;
609 __in._M_setstate(__ios_base::badbit);
610 __throw_exception_again;
617 __in._M_setstate(__ios_base::badbit);
622 __err |= __ios_base::failbit;
628 template<
typename _CharT,
typename _Traits,
typename _Alloc,
629 template <
typename,
typename,
typename>
class _Base>
630 basic_istream<_CharT, _Traits>&
636 typedef typename __istream_type::ios_base __ios_base;
639 typedef typename __istream_type::int_type __int_type;
640 typedef typename __string_type::size_type __size_type;
642 __size_type __extracted = 0;
643 const __size_type __n = __str.
max_size();
644 typename __ios_base::iostate __err = __ios_base::goodbit;
645 typename __istream_type::sentry __cerb(__in,
true);
653 __size_type __len = 0;
654 const __int_type __idelim = _Traits::to_int_type(__delim);
655 const __int_type __eof = _Traits::eof();
656 __int_type __c = __in.
rdbuf()->sgetc();
658 while (__extracted < __n
659 && !_Traits::eq_int_type(__c, __eof)
660 && !_Traits::eq_int_type(__c, __idelim))
662 if (__len ==
sizeof(__buf) /
sizeof(_CharT))
664 __str.
append(__buf,
sizeof(__buf) /
sizeof(_CharT));
667 __buf[__len++] = _Traits::to_char_type(__c);
669 __c = __in.
rdbuf()->snextc();
671 __str.
append(__buf, __len);
673 if (_Traits::eq_int_type(__c, __eof))
674 __err |= __ios_base::eofbit;
675 else if (_Traits::eq_int_type(__c, __idelim))
678 __in.
rdbuf()->sbumpc();
681 __err |= __ios_base::failbit;
685 __in._M_setstate(__ios_base::badbit);
686 __throw_exception_again;
693 __in._M_setstate(__ios_base::badbit);
697 __err |= __ios_base::failbit;
703_GLIBCXX_END_NAMESPACE_VERSION
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const _Facet & use_facet(const locale &__loc)
Return a facet.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
GNU extensions for public use.
void setstate(iostate __state)
Sets additional flags in the error state.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
Template class basic_istream.
Thrown as part of forced unwinding.
streamsize width() const
Flags access.
locale getloc() const
Locale access.
Primary class template ctype facet.
Template class __versa_string.
size_type find_last_of(const __versa_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
size_type find_first_not_of(const __versa_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
static const size_type npos
Value returned by various member functions when they fail.
size_type find_last_not_of(const __versa_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
size_type find_first_of(const __versa_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
__versa_string(const _Alloc &__a=_Alloc()) noexcept
Construct an empty string using allocator a.
__versa_string & append(const __versa_string &__str)
Append a string to this string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
const _CharT * data() const noexcept
Return const pointer to contents.
int compare(const __versa_string &__str) const
Compare to a string.
__versa_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
void push_back(_CharT __c)
Append a single character.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type rfind(const __versa_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.