STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vstring.h
Go to the documentation of this file.
1 // Versatile string -*- C++ -*-
2 
3 // Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
29 #ifndef _VSTRING_H
30 #define _VSTRING_H 1
31 
32 #pragma GCC system_header
33 
34 #if __cplusplus >= 201103L
35 #include <initializer_list>
36 #endif
37 
38 #include <ext/vstring_util.h>
39 #include <ext/rc_string_base.h>
40 #include <ext/sso_string_base.h>
41 
42 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
43 {
44 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 
54  template<typename _CharT, typename _Traits, typename _Alloc,
55  template <typename, typename, typename> class _Base>
56  class __versa_string
57  : private _Base<_CharT, _Traits, _Alloc>
58  {
59  typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
60  typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
61 
62  // Types:
63  public:
64  typedef _Traits traits_type;
65  typedef typename _Traits::char_type value_type;
66  typedef _Alloc allocator_type;
67  typedef typename _CharT_alloc_type::size_type size_type;
68  typedef typename _CharT_alloc_type::difference_type difference_type;
69  typedef value_type& reference;
70  typedef const value_type& const_reference;
71  typedef typename _CharT_alloc_type::pointer pointer;
72  typedef typename _CharT_alloc_type::const_pointer const_pointer;
73  typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
74  typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
75  const_iterator;
76  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
77  typedef std::reverse_iterator<iterator> reverse_iterator;
78 
79  // Data Member (public):
81  static const size_type npos = static_cast<size_type>(-1);
82 
83  private:
84  size_type
85  _M_check(size_type __pos, const char* __s) const
86  {
87  if (__pos > this->size())
88  std::__throw_out_of_range(__N(__s));
89  return __pos;
90  }
91 
92  void
93  _M_check_length(size_type __n1, size_type __n2, const char* __s) const
94  {
95  if (this->max_size() - (this->size() - __n1) < __n2)
96  std::__throw_length_error(__N(__s));
97  }
98 
99  // NB: _M_limit doesn't check for a bad __pos value.
100  size_type
101  _M_limit(size_type __pos, size_type __off) const
102  {
103  const bool __testoff = __off < this->size() - __pos;
104  return __testoff ? __off : this->size() - __pos;
105  }
106 
107  // True if _Rep and source do not overlap.
108  bool
109  _M_disjunct(const _CharT* __s) const
110  {
111  return (std::less<const _CharT*>()(__s, this->_M_data())
112  || std::less<const _CharT*>()(this->_M_data()
113  + this->size(), __s));
114  }
115 
116  // For the internal use we have functions similar to `begin'/`end'
117  // but they do not call _M_leak.
118  iterator
119  _M_ibegin() const
120  { return iterator(this->_M_data()); }
121 
122  iterator
123  _M_iend() const
124  { return iterator(this->_M_data() + this->_M_length()); }
125 
126  public:
127  // Construct/copy/destroy:
128  // NB: We overload ctors in some cases instead of using default
129  // arguments, per 17.4.4.4 para. 2 item 2.
130 
135  : __vstring_base() { }
136 
140  explicit
141  __versa_string(const _Alloc& __a)
142  : __vstring_base(__a) { }
143 
144  // NB: per LWG issue 42, semantics different from IS:
149  __versa_string(const __versa_string& __str)
150  : __vstring_base(__str) { }
151 
152 #if __cplusplus >= 201103L
153 
161  __versa_string(__versa_string&& __str) noexcept
162  : __vstring_base(std::move(__str)) { }
163 
169  __versa_string(std::initializer_list<_CharT> __l,
170  const _Alloc& __a = _Alloc())
171  : __vstring_base(__l.begin(), __l.end(), __a) { }
172 #endif
173 
180  __versa_string(const __versa_string& __str, size_type __pos,
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()) { }
187 
195  __versa_string(const __versa_string& __str, size_type __pos,
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)
201  + __pos, __a) { }
202 
212  __versa_string(const _CharT* __s, size_type __n,
213  const _Alloc& __a = _Alloc())
214  : __vstring_base(__s, __s + __n, __a) { }
215 
221  __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
222  : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
223  __s + npos, __a) { }
224 
231  __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
232  : __vstring_base(__n, __c, __a) { }
233 
240 #if __cplusplus >= 201103L
241  template<class _InputIterator,
242  typename = std::_RequireInputIter<_InputIterator>>
243 #else
244  template<class _InputIterator>
245 #endif
246  __versa_string(_InputIterator __beg, _InputIterator __end,
247  const _Alloc& __a = _Alloc())
248  : __vstring_base(__beg, __end, __a) { }
249 
253  ~__versa_string() _GLIBCXX_NOEXCEPT { }
254 
259  __versa_string&
260  operator=(const __versa_string& __str)
261  { return this->assign(__str); }
262 
263 #if __cplusplus >= 201103L
264 
271  __versa_string&
272  operator=(__versa_string&& __str)
273  {
274  // NB: DR 1204.
275  this->swap(__str);
276  return *this;
277  }
278 
283  __versa_string&
284  operator=(std::initializer_list<_CharT> __l)
285  {
286  this->assign(__l.begin(), __l.end());
287  return *this;
288  }
289 #endif
290 
295  __versa_string&
296  operator=(const _CharT* __s)
297  { return this->assign(__s); }
298 
306  __versa_string&
307  operator=(_CharT __c)
308  {
309  this->assign(1, __c);
310  return *this;
311  }
312 
313  // Iterators:
318  iterator
319  begin() _GLIBCXX_NOEXCEPT
320  {
321  this->_M_leak();
322  return iterator(this->_M_data());
323  }
324 
329  const_iterator
330  begin() const _GLIBCXX_NOEXCEPT
331  { return const_iterator(this->_M_data()); }
332 
337  iterator
338  end() _GLIBCXX_NOEXCEPT
339  {
340  this->_M_leak();
341  return iterator(this->_M_data() + this->size());
342  }
343 
348  const_iterator
349  end() const _GLIBCXX_NOEXCEPT
350  { return const_iterator(this->_M_data() + this->size()); }
351 
357  reverse_iterator
358  rbegin() _GLIBCXX_NOEXCEPT
359  { return reverse_iterator(this->end()); }
360 
366  const_reverse_iterator
367  rbegin() const _GLIBCXX_NOEXCEPT
368  { return const_reverse_iterator(this->end()); }
369 
375  reverse_iterator
376  rend() _GLIBCXX_NOEXCEPT
377  { return reverse_iterator(this->begin()); }
378 
384  const_reverse_iterator
385  rend() const _GLIBCXX_NOEXCEPT
386  { return const_reverse_iterator(this->begin()); }
387 
388 #if __cplusplus >= 201103L
389 
393  const_iterator
394  cbegin() const noexcept
395  { return const_iterator(this->_M_data()); }
396 
401  const_iterator
402  cend() const noexcept
403  { return const_iterator(this->_M_data() + this->size()); }
404 
410  const_reverse_iterator
411  crbegin() const noexcept
412  { return const_reverse_iterator(this->end()); }
413 
419  const_reverse_iterator
420  crend() const noexcept
421  { return const_reverse_iterator(this->begin()); }
422 #endif
423 
424  public:
425  // Capacity:
428  size_type
429  size() const _GLIBCXX_NOEXCEPT
430  { return this->_M_length(); }
431 
434  size_type
435  length() const _GLIBCXX_NOEXCEPT
436  { return this->_M_length(); }
437 
439  size_type
440  max_size() const _GLIBCXX_NOEXCEPT
441  { return this->_M_max_size(); }
442 
453  void
454  resize(size_type __n, _CharT __c);
455 
466  void
467  resize(size_type __n)
468  { this->resize(__n, _CharT()); }
469 
470 #if __cplusplus >= 201103L
471  void
473  shrink_to_fit()
474  {
475  if (capacity() > size())
476  {
477  __try
478  { this->reserve(0); }
479  __catch(...)
480  { }
481  }
482  }
483 #endif
484 
489  size_type
490  capacity() const _GLIBCXX_NOEXCEPT
491  { return this->_M_capacity(); }
492 
510  void
511  reserve(size_type __res_arg = 0)
512  { this->_M_reserve(__res_arg); }
513 
517  void
518  clear() _GLIBCXX_NOEXCEPT
519  { this->_M_clear(); }
520 
525  bool
526  empty() const _GLIBCXX_NOEXCEPT
527  { return this->size() == 0; }
528 
529  // Element access:
540  const_reference
541  operator[] (size_type __pos) const
542  {
543  _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
544  return this->_M_data()[__pos];
545  }
546 
557  reference
558  operator[](size_type __pos)
559  {
560  // allow pos == size() as v3 extension:
561  _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
562  // but be strict in pedantic mode:
563  _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
564  this->_M_leak();
565  return this->_M_data()[__pos];
566  }
567 
578  const_reference
579  at(size_type __n) const
580  {
581  if (__n >= this->size())
582  std::__throw_out_of_range(__N("__versa_string::at"));
583  return this->_M_data()[__n];
584  }
585 
597  reference
598  at(size_type __n)
599  {
600  if (__n >= this->size())
601  std::__throw_out_of_range(__N("__versa_string::at"));
602  this->_M_leak();
603  return this->_M_data()[__n];
604  }
605 
606 #if __cplusplus >= 201103L
607 
611  reference
612  front()
613  { return operator[](0); }
614 
619  const_reference
620  front() const
621  { return operator[](0); }
622 
627  reference
628  back()
629  { return operator[](this->size() - 1); }
630 
635  const_reference
636  back() const
637  { return operator[](this->size() - 1); }
638 #endif
639 
640  // Modifiers:
646  __versa_string&
647  operator+=(const __versa_string& __str)
648  { return this->append(__str); }
649 
655  __versa_string&
656  operator+=(const _CharT* __s)
657  { return this->append(__s); }
658 
664  __versa_string&
665  operator+=(_CharT __c)
666  {
667  this->push_back(__c);
668  return *this;
669  }
670 
671 #if __cplusplus >= 201103L
672 
677  __versa_string&
678  operator+=(std::initializer_list<_CharT> __l)
679  { return this->append(__l.begin(), __l.end()); }
680 #endif // C++11
681 
687  __versa_string&
688  append(const __versa_string& __str)
689  { return _M_append(__str._M_data(), __str.size()); }
690 
704  __versa_string&
705  append(const __versa_string& __str, size_type __pos, size_type __n)
706  { return _M_append(__str._M_data()
707  + __str._M_check(__pos, "__versa_string::append"),
708  __str._M_limit(__pos, __n)); }
709 
716  __versa_string&
717  append(const _CharT* __s, size_type __n)
718  {
720  _M_check_length(size_type(0), __n, "__versa_string::append");
721  return _M_append(__s, __n);
722  }
723 
729  __versa_string&
730  append(const _CharT* __s)
731  {
733  const size_type __n = traits_type::length(__s);
734  _M_check_length(size_type(0), __n, "__versa_string::append");
735  return _M_append(__s, __n);
736  }
737 
746  __versa_string&
747  append(size_type __n, _CharT __c)
748  { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
749 
750 #if __cplusplus >= 201103L
751 
756  __versa_string&
757  append(std::initializer_list<_CharT> __l)
758  { return this->append(__l.begin(), __l.end()); }
759 #endif // C++11
760 
769 #if __cplusplus >= 201103L
770  template<class _InputIterator,
771  typename = std::_RequireInputIter<_InputIterator>>
772 #else
773  template<class _InputIterator>
774 #endif
775  __versa_string&
776  append(_InputIterator __first, _InputIterator __last)
777  { return this->replace(_M_iend(), _M_iend(), __first, __last); }
778 
783  void
784  push_back(_CharT __c)
785  {
786  const size_type __size = this->size();
787  if (__size + 1 > this->capacity() || this->_M_is_shared())
788  this->_M_mutate(__size, size_type(0), 0, size_type(1));
789  traits_type::assign(this->_M_data()[__size], __c);
790  this->_M_set_length(__size + 1);
791  }
792 
798  __versa_string&
799  assign(const __versa_string& __str)
800  {
801  this->_M_assign(__str);
802  return *this;
803  }
804 
805 #if __cplusplus >= 201103L
806 
814  __versa_string&
815  assign(__versa_string&& __str)
816  {
817  this->swap(__str);
818  return *this;
819  }
820 #endif // C++11
821 
835  __versa_string&
836  assign(const __versa_string& __str, size_type __pos, size_type __n)
837  { return _M_replace(size_type(0), this->size(), __str._M_data()
838  + __str._M_check(__pos, "__versa_string::assign"),
839  __str._M_limit(__pos, __n)); }
840 
852  __versa_string&
853  assign(const _CharT* __s, size_type __n)
854  {
856  return _M_replace(size_type(0), this->size(), __s, __n);
857  }
858 
868  __versa_string&
869  assign(const _CharT* __s)
870  {
872  return _M_replace(size_type(0), this->size(), __s,
873  traits_type::length(__s));
874  }
875 
885  __versa_string&
886  assign(size_type __n, _CharT __c)
887  { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
888 
898 #if __cplusplus >= 201103L
899  template<class _InputIterator,
900  typename = std::_RequireInputIter<_InputIterator>>
901 #else
902  template<class _InputIterator>
903 #endif
904  __versa_string&
905  assign(_InputIterator __first, _InputIterator __last)
906  { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
907 
908 #if __cplusplus >= 201103L
909 
914  __versa_string&
915  assign(std::initializer_list<_CharT> __l)
916  { return this->assign(__l.begin(), __l.end()); }
917 #endif // C++11
918 
932  void
933  insert(iterator __p, size_type __n, _CharT __c)
934  { this->replace(__p, __p, __n, __c); }
935 
948 #if __cplusplus >= 201103L
949  template<class _InputIterator,
950  typename = std::_RequireInputIter<_InputIterator>>
951 #else
952  template<class _InputIterator>
953 #endif
954  void
955  insert(iterator __p, _InputIterator __beg, _InputIterator __end)
956  { this->replace(__p, __p, __beg, __end); }
957 
958 #if __cplusplus >= 201103L
959 
965  void
966  insert(iterator __p, std::initializer_list<_CharT> __l)
967  { this->insert(__p, __l.begin(), __l.end()); }
968 #endif // C++11
969 
982  __versa_string&
983  insert(size_type __pos1, const __versa_string& __str)
984  { return this->replace(__pos1, size_type(0),
985  __str._M_data(), __str.size()); }
986 
1005  __versa_string&
1006  insert(size_type __pos1, const __versa_string& __str,
1007  size_type __pos2, size_type __n)
1008  { return this->replace(__pos1, size_type(0), __str._M_data()
1009  + __str._M_check(__pos2, "__versa_string::insert"),
1010  __str._M_limit(__pos2, __n)); }
1011 
1028  __versa_string&
1029  insert(size_type __pos, const _CharT* __s, size_type __n)
1030  { return this->replace(__pos, size_type(0), __s, __n); }
1031 
1047  __versa_string&
1048  insert(size_type __pos, const _CharT* __s)
1049  {
1051  return this->replace(__pos, size_type(0), __s,
1052  traits_type::length(__s));
1053  }
1054 
1071  __versa_string&
1072  insert(size_type __pos, size_type __n, _CharT __c)
1073  { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
1074  size_type(0), __n, __c); }
1075 
1089  iterator
1090  insert(iterator __p, _CharT __c)
1091  {
1092  _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1093  const size_type __pos = __p - _M_ibegin();
1094  _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1095  this->_M_set_leaked();
1096  return iterator(this->_M_data() + __pos);
1097  }
1098 
1114  __versa_string&
1115  erase(size_type __pos = 0, size_type __n = npos)
1116  {
1117  this->_M_erase(_M_check(__pos, "__versa_string::erase"),
1118  _M_limit(__pos, __n));
1119  return *this;
1120  }
1121 
1130  iterator
1131  erase(iterator __position)
1132  {
1133  _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
1134  && __position < _M_iend());
1135  const size_type __pos = __position - _M_ibegin();
1136  this->_M_erase(__pos, size_type(1));
1137  this->_M_set_leaked();
1138  return iterator(this->_M_data() + __pos);
1139  }
1140 
1151  iterator
1152  erase(iterator __first, iterator __last)
1153  {
1154  _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
1155  && __last <= _M_iend());
1156  const size_type __pos = __first - _M_ibegin();
1157  this->_M_erase(__pos, __last - __first);
1158  this->_M_set_leaked();
1159  return iterator(this->_M_data() + __pos);
1160  }
1161 
1162 #if __cplusplus >= 201103L
1163 
1168  void
1169  pop_back()
1170  { this->_M_erase(size()-1, 1); }
1171 #endif // C++11
1172 
1190  __versa_string&
1191  replace(size_type __pos, size_type __n, const __versa_string& __str)
1192  { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
1193 
1213  __versa_string&
1214  replace(size_type __pos1, size_type __n1, const __versa_string& __str,
1215  size_type __pos2, size_type __n2)
1216  {
1217  return this->replace(__pos1, __n1, __str._M_data()
1218  + __str._M_check(__pos2,
1219  "__versa_string::replace"),
1220  __str._M_limit(__pos2, __n2));
1221  }
1222 
1241  __versa_string&
1242  replace(size_type __pos, size_type __n1, const _CharT* __s,
1243  size_type __n2)
1244  {
1245  __glibcxx_requires_string_len(__s, __n2);
1246  return _M_replace(_M_check(__pos, "__versa_string::replace"),
1247  _M_limit(__pos, __n1), __s, __n2);
1248  }
1249 
1265  __versa_string&
1266  replace(size_type __pos, size_type __n1, const _CharT* __s)
1267  {
1269  return this->replace(__pos, __n1, __s, traits_type::length(__s));
1270  }
1271 
1289  __versa_string&
1290  replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1291  { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
1292  _M_limit(__pos, __n1), __n2, __c); }
1293 
1307  __versa_string&
1308  replace(iterator __i1, iterator __i2, const __versa_string& __str)
1309  { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
1310 
1325  __versa_string&
1326  replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
1327  {
1328  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1329  && __i2 <= _M_iend());
1330  return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1331  }
1332 
1346  __versa_string&
1347  replace(iterator __i1, iterator __i2, const _CharT* __s)
1348  {
1350  return this->replace(__i1, __i2, __s, traits_type::length(__s));
1351  }
1352 
1367  __versa_string&
1368  replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1369  {
1370  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1371  && __i2 <= _M_iend());
1372  return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1373  }
1374 
1389 #if __cplusplus >= 201103L
1390  template<class _InputIterator,
1391  typename = std::_RequireInputIter<_InputIterator>>
1392  __versa_string&
1393  replace(iterator __i1, iterator __i2,
1394  _InputIterator __k1, _InputIterator __k2)
1395  {
1396  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1397  && __i2 <= _M_iend());
1398  __glibcxx_requires_valid_range(__k1, __k2);
1399  return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1400  std::__false_type());
1401  }
1402 #else
1403  template<class _InputIterator>
1404  __versa_string&
1405  replace(iterator __i1, iterator __i2,
1406  _InputIterator __k1, _InputIterator __k2)
1407  {
1408  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1409  && __i2 <= _M_iend());
1410  __glibcxx_requires_valid_range(__k1, __k2);
1411  typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1412  return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1413  }
1414 #endif
1415 
1416  // Specializations for the common case of pointer and iterator:
1417  // useful to avoid the overhead of temporary buffering in _M_replace.
1418  __versa_string&
1419  replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
1420  {
1421  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1422  && __i2 <= _M_iend());
1423  __glibcxx_requires_valid_range(__k1, __k2);
1424  return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1425  __k1, __k2 - __k1);
1426  }
1427 
1428  __versa_string&
1429  replace(iterator __i1, iterator __i2,
1430  const _CharT* __k1, const _CharT* __k2)
1431  {
1432  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1433  && __i2 <= _M_iend());
1434  __glibcxx_requires_valid_range(__k1, __k2);
1435  return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1436  __k1, __k2 - __k1);
1437  }
1438 
1439  __versa_string&
1440  replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
1441  {
1442  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1443  && __i2 <= _M_iend());
1444  __glibcxx_requires_valid_range(__k1, __k2);
1445  return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1446  __k1.base(), __k2 - __k1);
1447  }
1448 
1449  __versa_string&
1450  replace(iterator __i1, iterator __i2,
1451  const_iterator __k1, const_iterator __k2)
1452  {
1453  _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1454  && __i2 <= _M_iend());
1455  __glibcxx_requires_valid_range(__k1, __k2);
1456  return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
1457  __k1.base(), __k2 - __k1);
1458  }
1459 
1460 #if __cplusplus >= 201103L
1461 
1474  __versa_string& replace(iterator __i1, iterator __i2,
1475  std::initializer_list<_CharT> __l)
1476  { return this->replace(__i1, __i2, __l.begin(), __l.end()); }
1477 #endif // C++11
1478 
1479  private:
1480  template<class _Integer>
1481  __versa_string&
1482  _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
1483  _Integer __val, std::__true_type)
1484  { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1485 
1486  template<class _InputIterator>
1487  __versa_string&
1488  _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
1489  _InputIterator __k2, std::__false_type);
1490 
1491  __versa_string&
1492  _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1493  _CharT __c);
1494 
1495  __versa_string&
1496  _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
1497  const size_type __len2);
1498 
1499  __versa_string&
1500  _M_append(const _CharT* __s, size_type __n);
1501 
1502  public:
1503 
1516  size_type
1517  copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
1518 
1526  void
1527  swap(__versa_string& __s)
1528  { this->_M_swap(__s); }
1529 
1530  // String operations:
1537  const _CharT*
1538  c_str() const _GLIBCXX_NOEXCEPT
1539  { return this->_M_data(); }
1540 
1547  const _CharT*
1548  data() const _GLIBCXX_NOEXCEPT
1549  { return this->_M_data(); }
1550 
1554  allocator_type
1555  get_allocator() const _GLIBCXX_NOEXCEPT
1556  { return allocator_type(this->_M_get_allocator()); }
1557 
1570  size_type
1571  find(const _CharT* __s, size_type __pos, size_type __n) const;
1572 
1583  size_type
1584  find(const __versa_string& __str, size_type __pos = 0) const
1585  _GLIBCXX_NOEXCEPT
1586  { return this->find(__str.data(), __pos, __str.size()); }
1587 
1598  size_type
1599  find(const _CharT* __s, size_type __pos = 0) const
1600  {
1602  return this->find(__s, __pos, traits_type::length(__s));
1603  }
1604 
1615  size_type
1616  find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
1617 
1628  size_type
1629  rfind(const __versa_string& __str, size_type __pos = npos) const
1630  _GLIBCXX_NOEXCEPT
1631  { return this->rfind(__str.data(), __pos, __str.size()); }
1632 
1645  size_type
1646  rfind(const _CharT* __s, size_type __pos, size_type __n) const;
1647 
1658  size_type
1659  rfind(const _CharT* __s, size_type __pos = npos) const
1660  {
1662  return this->rfind(__s, __pos, traits_type::length(__s));
1663  }
1664 
1675  size_type
1676  rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
1677 
1688  size_type
1689  find_first_of(const __versa_string& __str, size_type __pos = 0) const
1690  _GLIBCXX_NOEXCEPT
1691  { return this->find_first_of(__str.data(), __pos, __str.size()); }
1692 
1705  size_type
1706  find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
1707 
1718  size_type
1719  find_first_of(const _CharT* __s, size_type __pos = 0) const
1720  {
1722  return this->find_first_of(__s, __pos, traits_type::length(__s));
1723  }
1724 
1737  size_type
1738  find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
1739  { return this->find(__c, __pos); }
1740 
1752  size_type
1753  find_last_of(const __versa_string& __str, size_type __pos = npos) const
1754  _GLIBCXX_NOEXCEPT
1755  { return this->find_last_of(__str.data(), __pos, __str.size()); }
1756 
1769  size_type
1770  find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
1771 
1782  size_type
1783  find_last_of(const _CharT* __s, size_type __pos = npos) const
1784  {
1786  return this->find_last_of(__s, __pos, traits_type::length(__s));
1787  }
1788 
1801  size_type
1802  find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
1803  { return this->rfind(__c, __pos); }
1804 
1815  size_type
1816  find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
1817  _GLIBCXX_NOEXCEPT
1818  { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
1819 
1832  size_type
1833  find_first_not_of(const _CharT* __s, size_type __pos,
1834  size_type __n) const;
1835 
1846  size_type
1847  find_first_not_of(const _CharT* __s, size_type __pos = 0) const
1848  {
1850  return this->find_first_not_of(__s, __pos, traits_type::length(__s));
1851  }
1852 
1863  size_type
1864  find_first_not_of(_CharT __c, size_type __pos = 0) const
1865  _GLIBCXX_NOEXCEPT;
1866 
1878  size_type
1879  find_last_not_of(const __versa_string& __str,
1880  size_type __pos = npos) const _GLIBCXX_NOEXCEPT
1881  { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
1882 
1895  size_type
1896  find_last_not_of(const _CharT* __s, size_type __pos,
1897  size_type __n) const;
1909  size_type
1910  find_last_not_of(const _CharT* __s, size_type __pos = npos) const
1911  {
1913  return this->find_last_not_of(__s, __pos, traits_type::length(__s));
1914  }
1915 
1926  size_type
1927  find_last_not_of(_CharT __c, size_type __pos = npos) const
1928  _GLIBCXX_NOEXCEPT;
1929 
1942  __versa_string
1943  substr(size_type __pos = 0, size_type __n = npos) const
1944  {
1945  return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
1946  __n);
1947  }
1948 
1963  int
1964  compare(const __versa_string& __str) const
1965  {
1966  if (this->_M_compare(__str))
1967  return 0;
1968 
1969  const size_type __size = this->size();
1970  const size_type __osize = __str.size();
1971  const size_type __len = std::min(__size, __osize);
1972 
1973  int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
1974  if (!__r)
1975  __r = this->_S_compare(__size, __osize);
1976  return __r;
1977  }
1978 
1998  int
1999  compare(size_type __pos, size_type __n,
2000  const __versa_string& __str) const;
2001 
2025  int
2026  compare(size_type __pos1, size_type __n1, const __versa_string& __str,
2027  size_type __pos2, size_type __n2) const;
2028 
2044  int
2045  compare(const _CharT* __s) const;
2046 
2047  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2048  // 5 String::compare specification questionable
2068  int
2069  compare(size_type __pos, size_type __n1, const _CharT* __s) const;
2070 
2095  int
2096  compare(size_type __pos, size_type __n1, const _CharT* __s,
2097  size_type __n2) const;
2098  };
2099 
2100  // operator+
2107  template<typename _CharT, typename _Traits, typename _Alloc,
2108  template <typename, typename, typename> class _Base>
2112 
2119  template<typename _CharT, typename _Traits, typename _Alloc,
2120  template <typename, typename, typename> class _Base>
2122  operator+(const _CharT* __lhs,
2124 
2131  template<typename _CharT, typename _Traits, typename _Alloc,
2132  template <typename, typename, typename> class _Base>
2134  operator+(_CharT __lhs,
2136 
2143  template<typename _CharT, typename _Traits, typename _Alloc,
2144  template <typename, typename, typename> class _Base>
2147  const _CharT* __rhs);
2148 
2155  template<typename _CharT, typename _Traits, typename _Alloc,
2156  template <typename, typename, typename> class _Base>
2159  _CharT __rhs);
2160 
2161 #if __cplusplus >= 201103L
2162  template<typename _CharT, typename _Traits, typename _Alloc,
2163  template <typename, typename, typename> class _Base>
2167  { return std::move(__lhs.append(__rhs)); }
2168 
2169  template<typename _CharT, typename _Traits, typename _Alloc,
2170  template <typename, typename, typename> class _Base>
2174  { return std::move(__rhs.insert(0, __lhs)); }
2175 
2176  template<typename _CharT, typename _Traits, typename _Alloc,
2177  template <typename, typename, typename> class _Base>
2181  {
2182  const auto __size = __lhs.size() + __rhs.size();
2183  const bool __cond = (__size > __lhs.capacity()
2184  && __size <= __rhs.capacity());
2185  return __cond ? std::move(__rhs.insert(0, __lhs))
2186  : std::move(__lhs.append(__rhs));
2187  }
2188 
2189  template<typename _CharT, typename _Traits, typename _Alloc,
2190  template <typename, typename, typename> class _Base>
2192  operator+(const _CharT* __lhs,
2194  { return std::move(__rhs.insert(0, __lhs)); }
2195 
2196  template<typename _CharT, typename _Traits, typename _Alloc,
2197  template <typename, typename, typename> class _Base>
2199  operator+(_CharT __lhs,
2201  { return std::move(__rhs.insert(0, 1, __lhs)); }
2202 
2203  template<typename _CharT, typename _Traits, typename _Alloc,
2204  template <typename, typename, typename> class _Base>
2207  const _CharT* __rhs)
2208  { return std::move(__lhs.append(__rhs)); }
2209 
2210  template<typename _CharT, typename _Traits, typename _Alloc,
2211  template <typename, typename, typename> class _Base>
2214  _CharT __rhs)
2215  { return std::move(__lhs.append(1, __rhs)); }
2216 #endif
2217 
2218  // operator ==
2225  template<typename _CharT, typename _Traits, typename _Alloc,
2226  template <typename, typename, typename> class _Base>
2227  inline bool
2230  { return __lhs.compare(__rhs) == 0; }
2231 
2232  template<typename _CharT,
2233  template <typename, typename, typename> class _Base>
2234  inline typename __enable_if<std::__is_char<_CharT>::__value, bool>::__type
2235  operator==(const __versa_string<_CharT, std::char_traits<_CharT>,
2236  std::allocator<_CharT>, _Base>& __lhs,
2237  const __versa_string<_CharT, std::char_traits<_CharT>,
2238  std::allocator<_CharT>, _Base>& __rhs)
2239  { return (__lhs.size() == __rhs.size()
2240  && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(),
2241  __lhs.size())); }
2242 
2249  template<typename _CharT, typename _Traits, typename _Alloc,
2250  template <typename, typename, typename> class _Base>
2251  inline bool
2252  operator==(const _CharT* __lhs,
2254  { return __rhs.compare(__lhs) == 0; }
2255 
2262  template<typename _CharT, typename _Traits, typename _Alloc,
2263  template <typename, typename, typename> class _Base>
2264  inline bool
2266  const _CharT* __rhs)
2267  { return __lhs.compare(__rhs) == 0; }
2268 
2269  // operator !=
2276  template<typename _CharT, typename _Traits, typename _Alloc,
2277  template <typename, typename, typename> class _Base>
2278  inline bool
2281  { return !(__lhs == __rhs); }
2282 
2289  template<typename _CharT, typename _Traits, typename _Alloc,
2290  template <typename, typename, typename> class _Base>
2291  inline bool
2292  operator!=(const _CharT* __lhs,
2294  { return !(__lhs == __rhs); }
2295 
2302  template<typename _CharT, typename _Traits, typename _Alloc,
2303  template <typename, typename, typename> class _Base>
2304  inline bool
2306  const _CharT* __rhs)
2307  { return !(__lhs == __rhs); }
2308 
2309  // operator <
2316  template<typename _CharT, typename _Traits, typename _Alloc,
2317  template <typename, typename, typename> class _Base>
2318  inline bool
2319  operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2321  { return __lhs.compare(__rhs) < 0; }
2322 
2329  template<typename _CharT, typename _Traits, typename _Alloc,
2330  template <typename, typename, typename> class _Base>
2331  inline bool
2332  operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2333  const _CharT* __rhs)
2334  { return __lhs.compare(__rhs) < 0; }
2335 
2342  template<typename _CharT, typename _Traits, typename _Alloc,
2343  template <typename, typename, typename> class _Base>
2344  inline bool
2345  operator<(const _CharT* __lhs,
2347  { return __rhs.compare(__lhs) > 0; }
2348 
2349  // operator >
2356  template<typename _CharT, typename _Traits, typename _Alloc,
2357  template <typename, typename, typename> class _Base>
2358  inline bool
2361  { return __lhs.compare(__rhs) > 0; }
2362 
2369  template<typename _CharT, typename _Traits, typename _Alloc,
2370  template <typename, typename, typename> class _Base>
2371  inline bool
2373  const _CharT* __rhs)
2374  { return __lhs.compare(__rhs) > 0; }
2375 
2382  template<typename _CharT, typename _Traits, typename _Alloc,
2383  template <typename, typename, typename> class _Base>
2384  inline bool
2385  operator>(const _CharT* __lhs,
2387  { return __rhs.compare(__lhs) < 0; }
2388 
2389  // operator <=
2396  template<typename _CharT, typename _Traits, typename _Alloc,
2397  template <typename, typename, typename> class _Base>
2398  inline bool
2399  operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2401  { return __lhs.compare(__rhs) <= 0; }
2402 
2409  template<typename _CharT, typename _Traits, typename _Alloc,
2410  template <typename, typename, typename> class _Base>
2411  inline bool
2412  operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
2413  const _CharT* __rhs)
2414  { return __lhs.compare(__rhs) <= 0; }
2415 
2422  template<typename _CharT, typename _Traits, typename _Alloc,
2423  template <typename, typename, typename> class _Base>
2424  inline bool
2425  operator<=(const _CharT* __lhs,
2427  { return __rhs.compare(__lhs) >= 0; }
2428 
2429  // operator >=
2436  template<typename _CharT, typename _Traits, typename _Alloc,
2437  template <typename, typename, typename> class _Base>
2438  inline bool
2441  { return __lhs.compare(__rhs) >= 0; }
2442 
2449  template<typename _CharT, typename _Traits, typename _Alloc,
2450  template <typename, typename, typename> class _Base>
2451  inline bool
2453  const _CharT* __rhs)
2454  { return __lhs.compare(__rhs) >= 0; }
2455 
2462  template<typename _CharT, typename _Traits, typename _Alloc,
2463  template <typename, typename, typename> class _Base>
2464  inline bool
2465  operator>=(const _CharT* __lhs,
2467  { return __rhs.compare(__lhs) <= 0; }
2468 
2476  template<typename _CharT, typename _Traits, typename _Alloc,
2477  template <typename, typename, typename> class _Base>
2478  inline void
2481  { __lhs.swap(__rhs); }
2482 
2483 _GLIBCXX_END_NAMESPACE_VERSION
2484 } // namespace
2485 
2486 namespace std _GLIBCXX_VISIBILITY(default)
2487 {
2488 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2489 
2502  template<typename _CharT, typename _Traits, typename _Alloc,
2503  template <typename, typename, typename> class _Base>
2504  basic_istream<_CharT, _Traits>&
2505  operator>>(basic_istream<_CharT, _Traits>& __is,
2506  __gnu_cxx::__versa_string<_CharT, _Traits,
2507  _Alloc, _Base>& __str);
2508 
2518  template<typename _CharT, typename _Traits, typename _Alloc,
2519  template <typename, typename, typename> class _Base>
2520  inline basic_ostream<_CharT, _Traits>&
2521  operator<<(basic_ostream<_CharT, _Traits>& __os,
2522  const __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
2523  _Base>& __str)
2524  {
2525  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2526  // 586. string inserter not a formatted function
2527  return __ostream_insert(__os, __str.data(), __str.size());
2528  }
2529 
2544  template<typename _CharT, typename _Traits, typename _Alloc,
2545  template <typename, typename, typename> class _Base>
2546  basic_istream<_CharT, _Traits>&
2547  getline(basic_istream<_CharT, _Traits>& __is,
2548  __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
2549  _CharT __delim);
2550 
2564  template<typename _CharT, typename _Traits, typename _Alloc,
2565  template <typename, typename, typename> class _Base>
2566  inline basic_istream<_CharT, _Traits>&
2567  getline(basic_istream<_CharT, _Traits>& __is,
2568  __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
2569  { return getline(__is, __str, __is.widen('\n')); }
2570 
2571 _GLIBCXX_END_NAMESPACE_VERSION
2572 } // namespace
2573 
2574 #if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
2575 
2576 #include <ext/string_conversions.h>
2577 
2578 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
2579 {
2580 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2581 
2582  // 21.4 Numeric Conversions [string.conversions].
2583  inline int
2584  stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
2585  { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
2586  __idx, __base); }
2587 
2588  inline long
2589  stol(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
2590  { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
2591  __idx, __base); }
2592 
2593  inline unsigned long
2594  stoul(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
2595  { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
2596  __idx, __base); }
2597 
2598  inline long long
2599  stoll(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
2600  { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
2601  __idx, __base); }
2602 
2603  inline unsigned long long
2604  stoull(const __vstring& __str, std::size_t* __idx, int __base = 10)
2605  { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
2606  __idx, __base); }
2607 
2608  // NB: strtof vs strtod.
2609  inline float
2610  stof(const __vstring& __str, std::size_t* __idx = 0)
2611  { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
2612 
2613  inline double
2614  stod(const __vstring& __str, std::size_t* __idx = 0)
2615  { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
2616 
2617  inline long double
2618  stold(const __vstring& __str, std::size_t* __idx = 0)
2619  { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
2620 
2621  // NB: (v)snprintf vs sprintf.
2622 
2623  // DR 1261.
2624  inline __vstring
2625  to_string(int __val)
2626  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(int),
2627  "%d", __val); }
2628 
2629  inline __vstring
2630  to_string(unsigned __val)
2631  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
2632  4 * sizeof(unsigned),
2633  "%u", __val); }
2634 
2635  inline __vstring
2636  to_string(long __val)
2637  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
2638  4 * sizeof(long),
2639  "%ld", __val); }
2640 
2641  inline __vstring
2642  to_string(unsigned long __val)
2643  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
2644  4 * sizeof(unsigned long),
2645  "%lu", __val); }
2646 
2647 
2648  inline __vstring
2649  to_string(long long __val)
2650  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
2651  4 * sizeof(long long),
2652  "%lld", __val); }
2653 
2654  inline __vstring
2655  to_string(unsigned long long __val)
2656  { return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
2657  4 * sizeof(unsigned long long),
2658  "%llu", __val); }
2659 
2660  inline __vstring
2661  to_string(float __val)
2662  {
2663  const int __n = __numeric_traits<float>::__max_exponent10 + 20;
2664  return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
2665  "%f", __val);
2666  }
2667 
2668  inline __vstring
2669  to_string(double __val)
2670  {
2671  const int __n = __numeric_traits<double>::__max_exponent10 + 20;
2672  return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
2673  "%f", __val);
2674  }
2675 
2676  inline __vstring
2677  to_string(long double __val)
2678  {
2679  const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
2680  return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
2681  "%Lf", __val);
2682  }
2683 
2684 #ifdef _GLIBCXX_USE_WCHAR_T
2685  inline int
2686  stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
2687  { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
2688  __idx, __base); }
2689 
2690  inline long
2691  stol(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
2692  { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
2693  __idx, __base); }
2694 
2695  inline unsigned long
2696  stoul(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
2697  { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
2698  __idx, __base); }
2699 
2700  inline long long
2701  stoll(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
2702  { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
2703  __idx, __base); }
2704 
2705  inline unsigned long long
2706  stoull(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
2707  { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
2708  __idx, __base); }
2709 
2710  // NB: wcstof vs wcstod.
2711  inline float
2712  stof(const __wvstring& __str, std::size_t* __idx = 0)
2713  { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
2714 
2715  inline double
2716  stod(const __wvstring& __str, std::size_t* __idx = 0)
2717  { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
2718 
2719  inline long double
2720  stold(const __wvstring& __str, std::size_t* __idx = 0)
2721  { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
2722 
2723 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2724  // DR 1261.
2725  inline __wvstring
2726  to_wstring(int __val)
2727  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2728  4 * sizeof(int),
2729  L"%d", __val); }
2730 
2731  inline __wvstring
2732  to_wstring(unsigned __val)
2733  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2734  4 * sizeof(unsigned),
2735  L"%u", __val); }
2736 
2737  inline __wvstring
2738  to_wstring(long __val)
2739  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2740  4 * sizeof(long),
2741  L"%ld", __val); }
2742 
2743  inline __wvstring
2744  to_wstring(unsigned long __val)
2745  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2746  4 * sizeof(unsigned long),
2747  L"%lu", __val); }
2748 
2749  inline __wvstring
2750  to_wstring(long long __val)
2751  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2752  4 * sizeof(long long),
2753  L"%lld", __val); }
2754 
2755  inline __wvstring
2756  to_wstring(unsigned long long __val)
2757  { return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
2758  4 * sizeof(unsigned long long),
2759  L"%llu", __val); }
2760 
2761  inline __wvstring
2762  to_wstring(float __val)
2763  {
2764  const int __n = __numeric_traits<float>::__max_exponent10 + 20;
2765  return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
2766  L"%f", __val);
2767  }
2768 
2769  inline __wvstring
2770  to_wstring(double __val)
2771  {
2772  const int __n = __numeric_traits<double>::__max_exponent10 + 20;
2773  return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
2774  L"%f", __val);
2775  }
2776 
2777  inline __wvstring
2778  to_wstring(long double __val)
2779  {
2780  const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
2781  return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
2782  L"%Lf", __val);
2783  }
2784 #endif
2785 #endif
2786 
2787 _GLIBCXX_END_NAMESPACE_VERSION
2788 } // namespace
2789 
2790 #endif
2791 
2792 #if __cplusplus >= 201103L
2793 
2794 #include <bits/functional_hash.h>
2795 
2796 namespace std _GLIBCXX_VISIBILITY(default)
2797 {
2798 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2799 
2801  template<>
2802  struct hash<__gnu_cxx::__vstring>
2803  : public __hash_base<size_t, __gnu_cxx::__vstring>
2804  {
2805  size_t
2806  operator()(const __gnu_cxx::__vstring& __s) const noexcept
2807  { return std::_Hash_impl::hash(__s.data(), __s.length()); }
2808  };
2809 
2810 #ifdef _GLIBCXX_USE_WCHAR_T
2811  template<>
2813  struct hash<__gnu_cxx::__wvstring>
2814  : public __hash_base<size_t, __gnu_cxx::__wvstring>
2815  {
2816  size_t
2817  operator()(const __gnu_cxx::__wvstring& __s) const noexcept
2818  { return std::_Hash_impl::hash(__s.data(),
2819  __s.length() * sizeof(wchar_t)); }
2820  };
2821 #endif
2822 
2823 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
2824  template<>
2826  struct hash<__gnu_cxx::__u16vstring>
2827  : public __hash_base<size_t, __gnu_cxx::__u16vstring>
2828  {
2829  size_t
2830  operator()(const __gnu_cxx::__u16vstring& __s) const noexcept
2831  { return std::_Hash_impl::hash(__s.data(),
2832  __s.length() * sizeof(char16_t)); }
2833  };
2834 
2836  template<>
2837  struct hash<__gnu_cxx::__u32vstring>
2838  : public __hash_base<size_t, __gnu_cxx::__u32vstring>
2839  {
2840  size_t
2841  operator()(const __gnu_cxx::__u32vstring& __s) const noexcept
2842  { return std::_Hash_impl::hash(__s.data(),
2843  __s.length() * sizeof(char32_t)); }
2844  };
2845 #endif
2846 
2847 _GLIBCXX_END_NAMESPACE_VERSION
2848 } // namespace
2849 
2850 #endif // C++11
2851 
2852 #include "vstring.tcc"
2853 
2854 #endif /* _VSTRING_H */
bool operator>=(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:644
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Definition: functions.h:446
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
std::size_t __size(__stack_t __stack)
Definition: profiler_node.h:68
#define __try
Definition: exception_defines.h:35
bool operator<=(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:580
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
#define __glibcxx_requires_string(_String)
Definition: debug.h:78
bool operator<(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:548
const _Tp & min(const _Tp &__a, const _Tp &__b)
Equivalent to std::min.
Definition: base.h:144
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Allocator > &__str)
Definition: string:1122
#define __glibcxx_requires_string_len(_String, _Len)
Definition: debug.h:79
_Safe_iterator< _Iterator, _Sequence > operator+(typename _Safe_iterator< _Iterator, _Sequence >::difference_type __n, const _Safe_iterator< _Iterator, _Sequence > &__i)
Definition: safe_iterator.h:712
namespace std _GLIBCXX_VISIBILITY(default)
Definition: vstring.h:2486
bool operator>(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:612
#define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
Definition: debug.h:62
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
__WCHAR_TYPE__ wchar_t
Definition: stddef.h:324
__SIZE_TYPE__ size_t
Definition: stddef.h:212
std::basic_istream< _CharT, _Traits > & getline(std::basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Allocator > &__str, _CharT __delim)
Definition: string:1132
#define __catch(X)
Definition: exception_defines.h:36
Definition: vstring.h:42
#define __glibcxx_requires_valid_range(_First, _Last)
Definition: debug.h:65
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160