60 :
private _Base<_CharT, _Traits, _Alloc>
62 typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
63 typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
68 typedef _Traits traits_type;
69 typedef typename _Traits::char_type value_type;
70 typedef _Alloc allocator_type;
71 typedef typename _CharT_alloc_type::size_type size_type;
72 typedef typename _CharT_alloc_type::difference_type difference_type;
73 typedef value_type& reference;
74 typedef const value_type& const_reference;
75 typedef typename _CharT_alloc_traits::pointer pointer;
76 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
77 typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
78 typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
85 static const size_type
npos =
static_cast<size_type
>(-1);
89 _M_check(size_type __pos,
const char* __s)
const
91 if (__pos > this->
size())
92 std::__throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
93 "this->size() (which is %zu)"),
94 __s, __pos, this->
size());
99 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
102 std::__throw_length_error(__N(__s));
107 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
109 const bool __testoff = __off < this->
size() - __pos;
110 return __testoff ? __off : this->
size() - __pos;
115 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
117 return (std::less<const _CharT*>()(__s, this->_M_data())
118 || std::less<const _CharT*>()(this->_M_data()
119 + this->
size(), __s));
125 _M_ibegin() const _GLIBCXX_NOEXCEPT
126 {
return iterator(this->_M_data()); }
129 _M_iend() const _GLIBCXX_NOEXCEPT
130 {
return iterator(this->_M_data() + this->_M_length()); }
142 : __vstring_base(__a) { }
150 : __vstring_base(__str) { }
152#if __cplusplus >= 201103L
170 const _Alloc& __a = _Alloc())
171 : __vstring_base(__l.
begin(), __l.
end(), __a) { }
181 size_type __n =
npos)
182 : __vstring_base(__str._M_data()
183 + __str._M_check(__pos,
184 "__versa_string::__versa_string"),
185 __str._M_data() + __str._M_limit(__pos, __n)
186 + __pos, _Alloc()) { }
196 size_type __n,
const _Alloc& __a)
197 : __vstring_base(__str._M_data()
198 + __str._M_check(__pos,
199 "__versa_string::__versa_string"),
200 __str._M_data() + __str._M_limit(__pos, __n)
213 const _Alloc& __a = _Alloc())
214 : __vstring_base(__s, __s + __n, __a) { }
222 : __vstring_base(__s, __s ? __s + traits_type::
length(__s) :
232 : __vstring_base(__n, __c, __a) { }
240#if __cplusplus >= 201103L
241 template<
class _InputIterator,
242 typename = std::_RequireInputIter<_InputIterator>>
244 template<
class _InputIterator>
247 const _Alloc& __a = _Alloc())
248 : __vstring_base(__beg, __end, __a) { }
261 {
return this->
assign(__str); }
263#if __cplusplus >= 201103L
286 this->
assign(__l.begin(), __l.end());
297 {
return this->
assign(__s); }
322 return iterator(this->_M_data());
331 {
return const_iterator(this->_M_data()); }
341 return iterator(this->_M_data() + this->
size());
349 end() const _GLIBCXX_NOEXCEPT
350 {
return const_iterator(this->_M_data() + this->
size()); }
359 {
return reverse_iterator(this->
end()); }
366 const_reverse_iterator
368 {
return const_reverse_iterator(this->
end()); }
377 {
return reverse_iterator(this->
begin()); }
384 const_reverse_iterator
386 {
return const_reverse_iterator(this->
begin()); }
388#if __cplusplus >= 201103L
395 {
return const_iterator(this->_M_data()); }
403 {
return const_iterator(this->_M_data() + this->
size()); }
410 const_reverse_iterator
412 {
return const_reverse_iterator(this->
end()); }
419 const_reverse_iterator
421 {
return const_reverse_iterator(this->
begin()); }
430 {
return this->_M_length(); }
436 {
return this->_M_length(); }
441 {
return this->_M_max_size(); }
468 { this->
resize(__n, _CharT()); }
470#if __cplusplus >= 201103L
491 {
return this->_M_capacity(); }
512 { this->_M_reserve(__res_arg); }
519 { this->_M_clear(); }
525 _GLIBCXX_NODISCARD
bool
527 {
return this->
size() == 0; }
543 __glibcxx_assert(__pos <= this->
size());
544 return this->_M_data()[__pos];
562 __glibcxx_assert(__pos <= this->
size());
564 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L
565 || __pos < this->
size());
567 return this->_M_data()[__pos];
581 at(size_type __n)
const
583 if (__n >= this->
size())
584 std::__throw_out_of_range_fmt(__N(
"__versa_string::at: __n "
585 "(which is %zu) >= this->size() "
588 return this->_M_data()[__n];
605 if (__n >= this->
size())
606 std::__throw_out_of_range_fmt(__N(
"__versa_string::at: __n "
607 "(which is %zu) >= this->size() "
611 return this->_M_data()[__n];
614#if __cplusplus >= 201103L
656 {
return this->
append(__str); }
665 {
return this->
append(__s); }
679#if __cplusplus >= 201103L
687 {
return this->
append(__l.begin(), __l.end()); }
697 {
return _M_append(__str._M_data(), __str.
size()); }
714 {
return _M_append(__str._M_data()
715 + __str._M_check(__pos,
"__versa_string::append"),
716 __str._M_limit(__pos, __n)); }
727 __glibcxx_requires_string_len(__s, __n);
728 _M_check_length(size_type(0), __n,
"__versa_string::append");
729 return _M_append(__s, __n);
740 __glibcxx_requires_string(__s);
741 const size_type __n = traits_type::length(__s);
742 _M_check_length(size_type(0), __n,
"__versa_string::append");
743 return _M_append(__s, __n);
756 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
758#if __cplusplus >= 201103L
766 {
return this->
append(__l.begin(), __l.end()); }
777#if __cplusplus >= 201103L
778 template<
class _InputIterator,
779 typename = std::_RequireInputIter<_InputIterator>>
781 template<
class _InputIterator>
784 append(_InputIterator __first, _InputIterator __last)
785 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
794 const size_type __size = this->
size();
795 if (__size + 1 > this->
capacity() || this->_M_is_shared())
796 this->_M_mutate(__size, size_type(0), 0, size_type(1));
797 traits_type::assign(this->_M_data()[__size], __c);
798 this->_M_set_length(__size + 1);
809 this->_M_assign(__str);
813#if __cplusplus >= 201103L
845 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
846 + __str._M_check(__pos,
"__versa_string::assign"),
847 __str._M_limit(__pos, __n)); }
863 __glibcxx_requires_string_len(__s, __n);
864 return _M_replace(size_type(0), this->
size(), __s, __n);
879 __glibcxx_requires_string(__s);
880 return _M_replace(size_type(0), this->
size(), __s,
881 traits_type::length(__s));
895 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
906#if __cplusplus >= 201103L
907 template<
class _InputIterator,
908 typename = std::_RequireInputIter<_InputIterator>>
910 template<
class _InputIterator>
913 assign(_InputIterator __first, _InputIterator __last)
914 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
916#if __cplusplus >= 201103L
924 {
return this->
assign(__l.begin(), __l.end()); }
927#if __cplusplus >= 201103L
944 insert(const_iterator __p, size_type __n, _CharT __c)
946 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
947 const size_type __pos = __p - _M_ibegin();
948 this->
replace(__p, __p, __n, __c);
949 return iterator(this->_M_data() + __pos);
966 insert(iterator __p, size_type __n, _CharT __c)
967 { this->
replace(__p, __p, __n, __c); }
970#if __cplusplus >= 201103L
985 template<
class _InputIterator,
986 typename = std::_RequireInputIter<_InputIterator>>
988 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
990 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
991 const size_type __pos = __p - _M_ibegin();
992 this->
replace(__p, __p, __beg, __end);
993 return iterator(this->_M_data() + __pos);
1008 template<
class _InputIterator>
1010 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1011 { this->
replace(__p, __p, __beg, __end); }
1014#if __cplusplus >= 201103L
1025 {
return this->
insert(__p, __l.begin(), __l.end()); }
1042 {
return this->
replace(__pos1, size_type(0),
1043 __str._M_data(), __str.
size()); }
1065 size_type __pos2, size_type __n)
1066 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1067 + __str._M_check(__pos2,
"__versa_string::insert"),
1068 __str._M_limit(__pos2, __n)); }
1087 insert(size_type __pos,
const _CharT* __s, size_type __n)
1088 {
return this->
replace(__pos, size_type(0), __s, __n); }
1108 __glibcxx_requires_string(__s);
1109 return this->
replace(__pos, size_type(0), __s,
1110 traits_type::length(__s));
1130 insert(size_type __pos, size_type __n, _CharT __c)
1131 {
return _M_replace_aux(_M_check(__pos,
"__versa_string::insert"),
1132 size_type(0), __n, __c); }
1148#if __cplusplus >= 201103L
1151 insert(iterator __p, _CharT __c)
1154 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1155 const size_type __pos = __p - _M_ibegin();
1156 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1157 this->_M_set_leaked();
1158 return iterator(this->_M_data() + __pos);
1179 this->_M_erase(_M_check(__pos,
"__versa_string::erase"),
1180 _M_limit(__pos, __n));
1193#if __cplusplus >= 201103L
1196 erase(iterator __position)
1199 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
1200 && __position < _M_iend());
1201 const size_type __pos = __position - _M_ibegin();
1202 this->_M_erase(__pos, size_type(1));
1203 this->_M_set_leaked();
1204 return iterator(this->_M_data() + __pos);
1218#if __cplusplus >= 201103L
1219 erase(const_iterator __first, const_iterator __last)
1221 erase(iterator __first, iterator __last)
1224 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
1225 && __last <= _M_iend());
1226 const size_type __pos = __first - _M_ibegin();
1227 this->_M_erase(__pos, __last - __first);
1228 this->_M_set_leaked();
1229 return iterator(this->_M_data() + __pos);
1232#if __cplusplus >= 201103L
1240 { this->_M_erase(
size()-1, 1); }
1262 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
1285 size_type __pos2, size_type __n2)
1287 return this->
replace(__pos1, __n1, __str._M_data()
1288 + __str._M_check(__pos2,
1289 "__versa_string::replace"),
1290 __str._M_limit(__pos2, __n2));
1312 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1315 __glibcxx_requires_string_len(__s, __n2);
1316 return _M_replace(_M_check(__pos,
"__versa_string::replace"),
1317 _M_limit(__pos, __n1), __s, __n2);
1336 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1338 __glibcxx_requires_string(__s);
1339 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1360 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1361 {
return _M_replace_aux(_M_check(__pos,
"__versa_string::replace"),
1362 _M_limit(__pos, __n1), __n2, __c); }
1378#if __cplusplus >= 201103L
1384 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
1401#if __cplusplus >= 201103L
1403 const _CharT* __s, size_type __n)
1405 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
1408 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1409 && __i2 <= _M_iend());
1410 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1427#if __cplusplus >= 201103L
1428 replace(const_iterator __i1, const_iterator __i2,
const _CharT* __s)
1430 replace(iterator __i1, iterator __i2,
const _CharT* __s)
1433 __glibcxx_requires_string(__s);
1434 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1452#if __cplusplus >= 201103L
1453 replace(const_iterator __i1, const_iterator __i2, size_type __n,
1456 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1459 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1460 && __i2 <= _M_iend());
1461 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1478#if __cplusplus >= 201103L
1479 template<
class _InputIterator,
1480 typename = std::_RequireInputIter<_InputIterator>>
1483 _InputIterator __k1, _InputIterator __k2)
1485 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1486 && __i2 <= _M_iend());
1487 __glibcxx_requires_valid_range(__k1, __k2);
1488 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1489 std::__false_type());
1492 template<
class _InputIterator>
1494 replace(iterator __i1, iterator __i2,
1495 _InputIterator __k1, _InputIterator __k2)
1497 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1498 && __i2 <= _M_iend());
1499 __glibcxx_requires_valid_range(__k1, __k2);
1500 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1501 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1508#if __cplusplus >= 201103L
1509 replace(const_iterator __i1, const_iterator __i2,
1510 _CharT* __k1, _CharT* __k2)
1512 replace(iterator __i1, iterator __i2,
1513 _CharT* __k1, _CharT* __k2)
1516 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1517 && __i2 <= _M_iend());
1518 __glibcxx_requires_valid_range(__k1, __k2);
1519 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1524#if __cplusplus >= 201103L
1525 replace(const_iterator __i1, const_iterator __i2,
1526 const _CharT* __k1,
const _CharT* __k2)
1528 replace(iterator __i1, iterator __i2,
1529 const _CharT* __k1,
const _CharT* __k2)
1532 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1533 && __i2 <= _M_iend());
1534 __glibcxx_requires_valid_range(__k1, __k2);
1535 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1540#if __cplusplus >= 201103L
1541 replace(const_iterator __i1, const_iterator __i2,
1542 iterator __k1, iterator __k2)
1544 replace(iterator __i1, iterator __i2,
1545 iterator __k1, iterator __k2)
1548 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1549 && __i2 <= _M_iend());
1550 __glibcxx_requires_valid_range(__k1, __k2);
1551 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1552 __k1.base(), __k2 - __k1);
1556#if __cplusplus >= 201103L
1557 replace(const_iterator __i1, const_iterator __i2,
1558 const_iterator __k1, const_iterator __k2)
1560 replace(iterator __i1, iterator __i2,
1561 const_iterator __k1, const_iterator __k2)
1564 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1565 && __i2 <= _M_iend());
1566 __glibcxx_requires_valid_range(__k1, __k2);
1567 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1568 __k1.base(), __k2 - __k1);
1571#if __cplusplus >= 201103L
1588 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1592 template<
class _Integer>
1594 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1595 _Integer __n, _Integer __val, std::__true_type)
1596 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1598 template<
class _InputIterator>
1600 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1601 _InputIterator __k1, _InputIterator __k2,
1605 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1609 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1610 const size_type __len2);
1613 _M_append(
const _CharT* __s, size_type __n);
1630 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1641 { this->_M_swap(__s); }
1652 {
return this->_M_data(); }
1662 {
return this->_M_data(); }
1669 {
return allocator_type(this->_M_get_allocator()); }
1684 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
1699 {
return this->
find(__str.
data(), __pos, __str.
size()); }
1712 find(
const _CharT* __s, size_type __pos = 0)
const
1714 __glibcxx_requires_string(__s);
1715 return this->
find(__s, __pos, traits_type::length(__s));
1729 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
1744 {
return this->
rfind(__str.data(), __pos, __str.size()); }
1759 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
1774 __glibcxx_requires_string(__s);
1775 return this->
rfind(__s, __pos, traits_type::length(__s));
1789 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
1834 __glibcxx_requires_string(__s);
1835 return this->
find_first_of(__s, __pos, traits_type::length(__s));
1852 {
return this->
find(__c, __pos); }
1898 __glibcxx_requires_string(__s);
1899 return this->
find_last_of(__s, __pos, traits_type::length(__s));
1916 {
return this->
rfind(__c, __pos); }
1947 size_type __n)
const;
1962 __glibcxx_requires_string(__s);
1993 size_type __pos =
npos) const _GLIBCXX_NOEXCEPT
2010 size_type __n)
const;
2025 __glibcxx_requires_string(__s);
2058 return __versa_string(*
this, _M_check(__pos,
"__versa_string::substr"),
2079 if (this->_M_compare(__str))
2082 const size_type __size = this->
size();
2083 const size_type __osize = __str.
size();
2084 const size_type __len =
std::min(__size, __osize);
2086 int __r = traits_type::compare(this->_M_data(), __str.
data(), __len);
2088 __r = this->_S_compare(__size, __osize);
2140 size_type __pos2, size_type __n2)
const;
2182 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2209 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2210 size_type __n2)
const;