36 #ifndef _BASIC_STRING_H
37 #define _BASIC_STRING_H 1
39 #pragma GCC system_header
45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
106 template<
typename _CharT,
typename _Traits,
typename _Alloc>
109 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
113 typedef _Traits traits_type;
114 typedef typename _Traits::char_type value_type;
115 typedef _Alloc allocator_type;
116 typedef typename _CharT_alloc_type::size_type size_type;
117 typedef typename _CharT_alloc_type::difference_type difference_type;
118 typedef typename _CharT_alloc_type::reference reference;
119 typedef typename _CharT_alloc_type::const_reference const_reference;
120 typedef typename _CharT_alloc_type::pointer pointer;
121 typedef typename _CharT_alloc_type::const_pointer const_pointer;
122 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
123 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
146 size_type _M_capacity;
147 _Atomic_word _M_refcount;
150 struct _Rep : _Rep_base
153 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
168 static const size_type _S_max_size;
169 static const _CharT _S_terminal;
173 static size_type _S_empty_rep_storage[];
181 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
182 return *
reinterpret_cast<_Rep*
>(__p);
187 {
return this->_M_refcount < 0; }
191 {
return this->_M_refcount > 0; }
195 { this->_M_refcount = -1; }
199 { this->_M_refcount = 0; }
202 _M_set_length_and_sharable(size_type __n)
204 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
205 if (__builtin_expect(
this != &_S_empty_rep(),
false))
208 this->_M_set_sharable();
209 this->_M_length = __n;
210 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
218 {
return reinterpret_cast<_CharT*
>(
this + 1); }
221 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
223 return (!_M_is_leaked() && __alloc1 == __alloc2)
224 ? _M_refcopy() : _M_clone(__alloc1);
229 _S_create(size_type, size_type,
const _Alloc&);
232 _M_dispose(
const _Alloc& __a)
234 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
235 if (__builtin_expect(
this != &_S_empty_rep(),
false))
239 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
240 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
243 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
250 _M_destroy(
const _Alloc&)
throw();
255 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
256 if (__builtin_expect(
this != &_S_empty_rep(),
false))
258 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
263 _M_clone(
const _Alloc&, size_type __res = 0);
267 struct _Alloc_hider : _Alloc
269 _Alloc_hider(_CharT* __dat,
const _Alloc& __a)
270 : _Alloc(__a), _M_p(__dat) { }
280 static const size_type
npos =
static_cast<size_type
>(-1);
284 mutable _Alloc_hider _M_dataplus;
288 {
return _M_dataplus._M_p; }
292 {
return (_M_dataplus._M_p = __p); }
296 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
302 {
return iterator(_M_data()); }
306 {
return iterator(_M_data() + this->
size()); }
311 if (!_M_rep()->_M_is_leaked())
316 _M_check(size_type __pos,
const char* __s)
const
318 if (__pos > this->
size())
319 __throw_out_of_range(__N(__s));
324 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
327 __throw_length_error(__N(__s));
332 _M_limit(size_type __pos, size_type __off)
const
334 const bool __testoff = __off < this->
size() - __pos;
335 return __testoff ? __off : this->
size() - __pos;
340 _M_disjunct(
const _CharT* __s)
const
342 return (less<const _CharT*>()(__s, _M_data())
343 || less<const _CharT*>()(_M_data() + this->
size(), __s));
349 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n)
352 traits_type::assign(*__d, *__s);
354 traits_type::copy(__d, __s, __n);
358 _M_move(_CharT* __d,
const _CharT* __s, size_type __n)
361 traits_type::assign(*__d, *__s);
363 traits_type::move(__d, __s, __n);
367 _M_assign(_CharT* __d, size_type __n, _CharT __c)
370 traits_type::assign(*__d, __c);
372 traits_type::assign(__d, __n, __c);
377 template<
class _Iterator>
379 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
381 for (; __k1 != __k2; ++__k1, ++__p)
382 traits_type::assign(*__p, *__k1);
386 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
387 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
390 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
391 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
394 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
395 { _M_copy(__p, __k1, __k2 - __k1); }
398 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
399 { _M_copy(__p, __k1, __k2 - __k1); }
402 _S_compare(size_type __n1, size_type __n2)
404 const difference_type __d = difference_type(__n1 - __n2);
406 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
407 return __gnu_cxx::__numeric_traits<int>::__max;
408 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
409 return __gnu_cxx::__numeric_traits<int>::__min;
415 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
422 {
return _Rep::_S_empty_rep(); }
433 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
434 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
436 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
458 size_type __n =
npos);
467 size_type __n,
const _Alloc& __a);
479 const _Alloc& __a = _Alloc());
485 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
492 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
494 #ifdef __GXX_EXPERIMENTAL_CXX0X__
503 : _M_dataplus(__str._M_dataplus)
505 #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
506 __str._M_data(_S_empty_rep()._M_refdata());
508 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
518 #endif // __GXX_EXPERIMENTAL_CXX0X__
526 template<
class _InputIterator>
527 basic_string(_InputIterator __beg, _InputIterator __end,
528 const _Alloc& __a = _Alloc());
542 {
return this->
assign(__str); }
550 {
return this->
assign(__s); }
566 #ifdef __GXX_EXPERIMENTAL_CXX0X__
589 this->
assign(__l.begin(), __l.size());
592 #endif // __GXX_EXPERIMENTAL_CXX0X__
603 return iterator(_M_data());
612 {
return const_iterator(_M_data()); }
622 return iterator(_M_data() + this->
size());
631 {
return const_iterator(_M_data() + this->
size()); }
647 const_reverse_iterator
665 const_reverse_iterator
669 #ifdef __GXX_EXPERIMENTAL_CXX0X__
676 {
return const_iterator(this->_M_data()); }
684 {
return const_iterator(this->_M_data() + this->
size()); }
691 const_reverse_iterator
700 const_reverse_iterator
711 {
return _M_rep()->_M_length; }
717 {
return _M_rep()->_M_length; }
722 {
return _Rep::_S_max_size; }
735 resize(size_type __n, _CharT __c);
749 { this->
resize(__n, _CharT()); }
751 #ifdef __GXX_EXPERIMENTAL_CXX0X__
769 {
return _M_rep()->_M_capacity; }
789 reserve(size_type __res_arg = 0);
796 { _M_mutate(0, this->
size(), 0); }
804 {
return this->
size() == 0; }
820 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
821 return _M_data()[__pos];
838 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
840 _GLIBCXX_DEBUG_PEDASSERT(__pos <
size());
842 return _M_data()[__pos];
856 at(size_type __n)
const
858 if (__n >= this->
size())
859 __throw_out_of_range(__N(
"basic_string::at"));
860 return _M_data()[__n];
863 #ifdef __GXX_EXPERIMENTAL_CXX0X__
912 __throw_out_of_range(__N(
"basic_string::at"));
914 return _M_data()[__n];
925 {
return this->
append(__str); }
934 {
return this->
append(__s); }
948 #ifdef __GXX_EXPERIMENTAL_CXX0X__
956 {
return this->
append(__l.begin(), __l.size()); }
957 #endif // __GXX_EXPERIMENTAL_CXX0X__
989 append(
const _CharT* __s, size_type __n);
999 __glibcxx_requires_string(__s);
1000 return this->
append(__s, traits_type::length(__s));
1012 append(size_type __n, _CharT __c);
1014 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1022 {
return this->
append(__l.begin(), __l.size()); }
1023 #endif // __GXX_EXPERIMENTAL_CXX0X__
1033 template<
class _InputIterator>
1035 append(_InputIterator __first, _InputIterator __last)
1036 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
1045 const size_type __len = 1 + this->
size();
1046 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
1048 traits_type::assign(_M_data()[this->
size()], __c);
1049 _M_rep()->_M_set_length_and_sharable(__len);
1060 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1075 #endif // __GXX_EXPERIMENTAL_CXX0X__
1091 {
return this->
assign(__str._M_data()
1092 + __str._M_check(__pos,
"basic_string::assign"),
1093 __str._M_limit(__pos, __n)); }
1106 assign(
const _CharT* __s, size_type __n);
1120 __glibcxx_requires_string(__s);
1121 return this->
assign(__s, traits_type::length(__s));
1135 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1145 template<
class _InputIterator>
1147 assign(_InputIterator __first, _InputIterator __last)
1148 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
1150 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1158 {
return this->
assign(__l.begin(), __l.size()); }
1159 #endif // __GXX_EXPERIMENTAL_CXX0X__
1174 insert(iterator __p, size_type __n, _CharT __c)
1175 { this->
replace(__p, __p, __n, __c); }
1188 template<
class _InputIterator>
1190 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1191 { this->
replace(__p, __p, __beg, __end); }
1193 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1203 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1204 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
1206 #endif // __GXX_EXPERIMENTAL_CXX0X__
1221 {
return this->
insert(__pos1, __str, size_type(0), __str.
size()); }
1243 size_type __pos2, size_type __n)
1244 {
return this->
insert(__pos1, __str._M_data()
1245 + __str._M_check(__pos2,
"basic_string::insert"),
1246 __str._M_limit(__pos2, __n)); }
1265 insert(size_type __pos,
const _CharT* __s, size_type __n);
1285 __glibcxx_requires_string(__s);
1286 return this->
insert(__pos, __s, traits_type::length(__s));
1306 insert(size_type __pos, size_type __n, _CharT __c)
1307 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1308 size_type(0), __n, __c); }
1325 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1326 const size_type __pos = __p - _M_ibegin();
1327 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1328 _M_rep()->_M_set_leaked();
1329 return iterator(_M_data() + __pos);
1349 _M_mutate(_M_check(__pos,
"basic_string::erase"),
1350 _M_limit(__pos, __n), size_type(0));
1365 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
1366 && __position < _M_iend());
1367 const size_type __pos = __position - _M_ibegin();
1368 _M_mutate(__pos, size_type(1), size_type(0));
1369 _M_rep()->_M_set_leaked();
1370 return iterator(_M_data() + __pos);
1403 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
1425 size_type __pos2, size_type __n2)
1426 {
return this->
replace(__pos1, __n1, __str._M_data()
1427 + __str._M_check(__pos2,
"basic_string::replace"),
1428 __str._M_limit(__pos2, __n2)); }
1448 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1467 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1469 __glibcxx_requires_string(__s);
1470 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1490 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1491 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1492 _M_limit(__pos, __n1), __n2, __c); }
1509 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
1526 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
1528 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1529 && __i2 <= _M_iend());
1530 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
1547 replace(iterator __i1, iterator __i2,
const _CharT* __s)
1549 __glibcxx_requires_string(__s);
1550 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1568 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
1570 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1571 && __i2 <= _M_iend());
1572 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
1589 template<
class _InputIterator>
1592 _InputIterator __k1, _InputIterator __k2)
1594 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1595 && __i2 <= _M_iend());
1596 __glibcxx_requires_valid_range(__k1, __k2);
1597 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1598 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1606 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1607 && __i2 <= _M_iend());
1608 __glibcxx_requires_valid_range(__k1, __k2);
1609 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1614 replace(iterator __i1, iterator __i2,
1615 const _CharT* __k1,
const _CharT* __k2)
1617 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1618 && __i2 <= _M_iend());
1619 __glibcxx_requires_valid_range(__k1, __k2);
1620 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1625 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
1627 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1628 && __i2 <= _M_iend());
1629 __glibcxx_requires_valid_range(__k1, __k2);
1630 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1631 __k1.base(), __k2 - __k1);
1635 replace(iterator __i1, iterator __i2,
1636 const_iterator __k1, const_iterator __k2)
1638 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
1639 && __i2 <= _M_iend());
1640 __glibcxx_requires_valid_range(__k1, __k2);
1641 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
1642 __k1.base(), __k2 - __k1);
1645 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1661 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1662 #endif // __GXX_EXPERIMENTAL_CXX0X__
1665 template<
class _Integer>
1668 _Integer __val, __true_type)
1669 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
1671 template<
class _InputIterator>
1673 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
1674 _InputIterator __k2, __false_type);
1677 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1681 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
1686 template<
class _InIterator>
1688 _S_construct_aux(_InIterator __beg, _InIterator __end,
1689 const _Alloc& __a, __false_type)
1691 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
1692 return _S_construct(__beg, __end, __a, _Tag());
1697 template<
class _Integer>
1699 _S_construct_aux(_Integer __beg, _Integer __end,
1700 const _Alloc& __a, __true_type)
1701 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
1705 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
1706 {
return _S_construct(__req, __c, __a); }
1708 template<
class _InIterator>
1710 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
1712 typedef typename std::__is_integer<_InIterator>::__type _Integral;
1713 return _S_construct_aux(__beg, __end, __a, _Integral());
1717 template<
class _InIterator>
1719 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
1720 input_iterator_tag);
1724 template<
class _FwdIterator>
1726 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
1727 forward_iterator_tag);
1730 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
1746 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1767 {
return _M_data(); }
1777 {
return _M_data(); }
1784 {
return _M_dataplus; }
1798 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
1812 {
return this->
find(__str.
data(), __pos, __str.
size()); }
1825 find(
const _CharT* __s, size_type __pos = 0)
const
1827 __glibcxx_requires_string(__s);
1828 return this->
find(__s, __pos, traits_type::length(__s));
1842 find(_CharT __c, size_type __pos = 0)
const;
1870 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
1885 __glibcxx_requires_string(__s);
1886 return this->
rfind(__s, __pos, traits_type::length(__s));
1900 rfind(_CharT __c, size_type __pos =
npos)
const;
1928 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
1943 __glibcxx_requires_string(__s);
1944 return this->
find_first_of(__s, __pos, traits_type::length(__s));
1961 {
return this->
find(__c, __pos); }
1989 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2004 __glibcxx_requires_string(__s);
2005 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2022 {
return this->
rfind(__c, __pos); }
2051 size_type __n)
const;
2066 __glibcxx_requires_string(__s);
2111 size_type __n)
const;
2125 __glibcxx_requires_string(__s);
2157 _M_check(__pos,
"basic_string::substr"), __n); }
2175 const size_type __size = this->
size();
2176 const size_type __osize = __str.
size();
2177 const size_type __len =
std::min(__size, __osize);
2179 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
2181 __r = _S_compare(__size, __osize);
2228 size_type __pos2, size_type __n2)
const;
2245 compare(
const _CharT* __s)
const;
2268 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2293 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2294 size_type __n2)
const;
2304 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2305 basic_string<_CharT, _Traits, _Alloc>
2320 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2321 basic_string<_CharT,_Traits,_Alloc>
2323 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
2331 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2332 basic_string<_CharT,_Traits,_Alloc>
2333 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
2341 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2342 inline basic_string<_CharT, _Traits, _Alloc>
2344 const _CharT* __rhs)
2357 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2358 inline basic_string<_CharT, _Traits, _Alloc>
2362 typedef typename __string_type::size_type __size_type;
2363 __string_type __str(__lhs);
2364 __str.append(__size_type(1), __rhs);
2368 #ifdef __GXX_EXPERIMENTAL_CXX0X__
2369 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2370 inline basic_string<_CharT, _Traits, _Alloc>
2371 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
2372 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
2373 {
return std::move(__lhs.append(__rhs)); }
2375 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2376 inline basic_string<_CharT, _Traits, _Alloc>
2377 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2378 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
2379 {
return std::move(__rhs.insert(0, __lhs)); }
2381 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2382 inline basic_string<_CharT, _Traits, _Alloc>
2383 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
2384 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
2386 const auto __size = __lhs.size() + __rhs.size();
2387 const bool __cond = (__size > __lhs.capacity()
2388 && __size <= __rhs.capacity());
2389 return __cond ? std::move(__rhs.insert(0, __lhs))
2390 : std::move(__lhs.append(__rhs));
2393 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2394 inline basic_string<_CharT, _Traits, _Alloc>
2396 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
2397 {
return std::move(__rhs.insert(0, __lhs)); }
2399 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2400 inline basic_string<_CharT, _Traits, _Alloc>
2402 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
2403 {
return std::move(__rhs.insert(0, 1, __lhs)); }
2405 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2406 inline basic_string<_CharT, _Traits, _Alloc>
2407 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
2408 const _CharT* __rhs)
2409 {
return std::move(__lhs.append(__rhs)); }
2411 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2412 inline basic_string<_CharT, _Traits, _Alloc>
2413 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
2415 {
return std::move(__lhs.append(1, __rhs)); }
2425 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2429 {
return __lhs.
compare(__rhs) == 0; }
2431 template<
typename _CharT>
2433 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
2434 operator==(
const basic_string<_CharT>& __lhs,
2435 const basic_string<_CharT>& __rhs)
2436 {
return (__lhs.size() == __rhs.size()
2446 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2448 operator==(
const _CharT* __lhs,
2450 {
return __rhs.
compare(__lhs) == 0; }
2458 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2461 const _CharT* __rhs)
2462 {
return __lhs.
compare(__rhs) == 0; }
2471 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2475 {
return !(__lhs == __rhs); }
2483 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2485 operator!=(
const _CharT* __lhs,
2487 {
return !(__lhs == __rhs); }
2495 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2498 const _CharT* __rhs)
2499 {
return !(__lhs == __rhs); }
2508 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2510 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2512 {
return __lhs.
compare(__rhs) < 0; }
2520 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2522 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2523 const _CharT* __rhs)
2524 {
return __lhs.compare(__rhs) < 0; }
2532 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2534 operator<(
const _CharT* __lhs,
2536 {
return __rhs.
compare(__lhs) > 0; }
2545 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2549 {
return __lhs.
compare(__rhs) > 0; }
2557 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2560 const _CharT* __rhs)
2561 {
return __lhs.
compare(__rhs) > 0; }
2569 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2571 operator>(
const _CharT* __lhs,
2573 {
return __rhs.
compare(__lhs) < 0; }
2582 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2584 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2586 {
return __lhs.
compare(__rhs) <= 0; }
2594 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2596 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
2597 const _CharT* __rhs)
2598 {
return __lhs.compare(__rhs) <= 0; }
2606 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2608 operator<=(
const _CharT* __lhs,
2610 {
return __rhs.
compare(__lhs) >= 0; }
2619 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2623 {
return __lhs.
compare(__rhs) >= 0; }
2631 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2634 const _CharT* __rhs)
2635 {
return __lhs.
compare(__rhs) >= 0; }
2643 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2645 operator>=(
const _CharT* __lhs,
2647 {
return __rhs.
compare(__lhs) <= 0; }
2656 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2660 { __lhs.
swap(__rhs); }
2673 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2674 basic_istream<_CharT, _Traits>&
2675 operator>>(basic_istream<_CharT, _Traits>& __is,
2676 basic_string<_CharT, _Traits, _Alloc>& __str);
2679 basic_istream<char>&
2680 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
2691 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2692 inline basic_ostream<_CharT, _Traits>&
2693 operator<<(basic_ostream<_CharT, _Traits>& __os,
2698 return __ostream_insert(__os, __str.data(), __str.size());
2714 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2715 basic_istream<_CharT, _Traits>&
2716 getline(basic_istream<_CharT, _Traits>& __is,
2717 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
2732 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2733 inline basic_istream<_CharT, _Traits>&
2739 basic_istream<char>&
2740 getline(basic_istream<char>& __in, basic_string<char>& __str,
2743 #ifdef _GLIBCXX_USE_WCHAR_T
2745 basic_istream<wchar_t>&
2746 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
2750 _GLIBCXX_END_NAMESPACE_VERSION
2753 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \
2754 && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
2758 namespace std _GLIBCXX_VISIBILITY(default)
2760 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2764 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
2765 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
2769 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
2770 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
2773 inline unsigned long
2774 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
2775 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
2779 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
2780 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
2783 inline unsigned long long
2784 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
2785 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
2790 stof(
const string& __str,
size_t* __idx = 0)
2791 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
2794 stod(
const string& __str,
size_t* __idx = 0)
2795 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
2798 stold(
const string& __str,
size_t* __idx = 0)
2799 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
2806 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
2811 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
2812 4 *
sizeof(unsigned),
2817 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
2822 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
2823 4 *
sizeof(
unsigned long),
2828 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
2829 4 *
sizeof(
long long),
2834 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
2835 4 *
sizeof(
unsigned long long),
2842 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
2843 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
2851 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
2852 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
2860 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
2861 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
2865 #ifdef _GLIBCXX_USE_WCHAR_T
2867 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
2868 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
2872 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
2873 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
2876 inline unsigned long
2877 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
2878 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
2882 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
2883 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
2886 inline unsigned long long
2887 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
2888 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
2893 stof(
const wstring& __str,
size_t* __idx = 0)
2894 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
2897 stod(
const wstring& __str,
size_t* __idx = 0)
2898 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
2901 stold(
const wstring& __str,
size_t* __idx = 0)
2902 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
2906 to_wstring(
int __val)
2907 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
2911 to_wstring(
unsigned __val)
2912 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
2913 4 *
sizeof(unsigned),
2917 to_wstring(
long __val)
2918 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
2922 to_wstring(
unsigned long __val)
2923 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
2924 4 *
sizeof(
unsigned long),
2928 to_wstring(
long long __val)
2929 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
2930 4 *
sizeof(
long long),
2934 to_wstring(
unsigned long long __val)
2935 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
2936 4 *
sizeof(
unsigned long long),
2940 to_wstring(
float __val)
2943 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
2944 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
2949 to_wstring(
double __val)
2952 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
2953 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
2958 to_wstring(
long double __val)
2961 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
2962 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
2967 _GLIBCXX_END_NAMESPACE_VERSION
2972 #ifdef __GXX_EXPERIMENTAL_CXX0X__
2976 namespace std _GLIBCXX_VISIBILITY(default)
2978 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2982 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
2986 :
public __hash_base<size_t, string>
2989 operator()(
const string& __s)
const
2990 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
2993 #ifdef _GLIBCXX_USE_WCHAR_T
2997 :
public __hash_base<size_t, wstring>
3000 operator()(
const wstring& __s)
const
3001 {
return std::_Hash_impl::hash(__s.
data(),
3002 __s.
length() *
sizeof(wchar_t)); }
3007 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
3011 :
public __hash_base<size_t, u16string>
3015 {
return std::_Hash_impl::hash(__s.
data(),
3016 __s.
length() *
sizeof(char16_t)); }
3022 :
public __hash_base<size_t, u32string>
3026 {
return std::_Hash_impl::hash(__s.
data(),
3027 __s.
length() *
sizeof(char32_t)); }
3031 _GLIBCXX_END_NAMESPACE_VERSION