1 // Versatile string -*- C++ -*-
3 // Copyright (C) 2005-2022 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25 /** @file ext/vstring.h
26 * This file is a GNU extension to the Standard C++ Library.
32 #pragma GCC system_header
34 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
36 #if __cplusplus >= 201103L
37 #include <initializer_list>
40 #include <ext/vstring_util.h>
41 #include <ext/rc_string_base.h>
42 #include <ext/sso_string_base.h>
43 #include <bits/stl_algobase.h> // std::min
45 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 * @class __versa_string vstring.h
51 * @brief Template class __versa_string.
54 * Data structure managing sequences of characters and
55 * character-like objects.
57 template<typename _CharT
, typename _Traits
, typename _Alloc
,
58 template <typename
, typename
, typename
> class _Base
>
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
;
64 typedef __alloc_traits
<_CharT_alloc_type
> _CharT_alloc_traits
;
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
>
80 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
81 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
83 // Data Member (public):
84 /// Value returned by various member functions when they fail.
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
101 if (this->max_size() - (this->size() - __n1
) < __n2
)
102 std::__throw_length_error(__N(__s
));
105 // NB: _M_limit doesn't check for a bad __pos value.
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
;
113 // True if _Rep and source do not overlap.
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
));
122 // For the internal use we have functions similar to `begin'/`end'
123 // but they do not call _M_leak.
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()); }
133 // Construct/copy/destroy:
134 // NB: We overload ctors in some cases instead of using default
135 // arguments, per 17.4.4.4 para. 2 item 2.
138 * @brief Construct an empty string using allocator @a a.
141 __versa_string(const _Alloc
& __a
= _Alloc()) _GLIBCXX_NOEXCEPT
142 : __vstring_base(__a
) { }
144 // NB: per LWG issue 42, semantics different from IS:
146 * @brief Construct string with copy of value of @a __str.
147 * @param __str Source string.
149 __versa_string(const __versa_string
& __str
)
150 : __vstring_base(__str
) { }
152 #if __cplusplus >= 201103L
154 * @brief String move constructor.
155 * @param __str Source string.
157 * The newly-constructed %string contains the exact contents of
158 * @a __str. The contents of @a __str are a valid, but unspecified
161 __versa_string(__versa_string
&& __str
) noexcept
162 : __vstring_base(std::move(__str
)) { }
165 * @brief Construct string from an initializer list.
166 * @param __l std::initializer_list of characters.
167 * @param __a Allocator to use (default is default allocator).
169 __versa_string(std::initializer_list
<_CharT
> __l
,
170 const _Alloc
& __a
= _Alloc())
171 : __vstring_base(__l
.begin(), __l
.end(), __a
) { }
175 * @brief Construct string as copy of a substring.
176 * @param __str Source string.
177 * @param __pos Index of first character to copy from.
178 * @param __n Number of characters to copy (default remainder).
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()) { }
189 * @brief Construct string as copy of a substring.
190 * @param __str Source string.
191 * @param __pos Index of first character to copy from.
192 * @param __n Number of characters to copy.
193 * @param __a Allocator to use.
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
)
204 * @brief Construct string initialized by a character array.
205 * @param __s Source character array.
206 * @param __n Number of characters to copy.
207 * @param __a Allocator to use (default is default allocator).
209 * NB: @a __s must have at least @a __n characters, '\\0' has no special
212 __versa_string(const _CharT
* __s
, size_type __n
,
213 const _Alloc
& __a
= _Alloc())
214 : __vstring_base(__s
, __s
+ __n
, __a
) { }
217 * @brief Construct string as copy of a C string.
218 * @param __s Source C string.
219 * @param __a Allocator to use (default is default allocator).
221 __versa_string(const _CharT
* __s
, const _Alloc
& __a
= _Alloc())
222 : __vstring_base(__s
, __s
? __s
+ traits_type::length(__s
) :
226 * @brief Construct string as multiple characters.
227 * @param __n Number of characters.
228 * @param __c Character to use.
229 * @param __a Allocator to use (default is default allocator).
231 __versa_string(size_type __n
, _CharT __c
, const _Alloc
& __a
= _Alloc())
232 : __vstring_base(__n
, __c
, __a
) { }
235 * @brief Construct string as copy of a range.
236 * @param __beg Start of range.
237 * @param __end End of range.
238 * @param __a Allocator to use (default is default allocator).
240 #if __cplusplus >= 201103L
241 template<class _InputIterator
,
242 typename
= std::_RequireInputIter
<_InputIterator
>>
244 template<class _InputIterator
>
246 __versa_string(_InputIterator __beg
, _InputIterator __end
,
247 const _Alloc
& __a
= _Alloc())
248 : __vstring_base(__beg
, __end
, __a
) { }
251 * @brief Destroy the string instance.
253 ~__versa_string() _GLIBCXX_NOEXCEPT
{ }
256 * @brief Assign the value of @a str to this string.
257 * @param __str Source string.
260 operator=(const __versa_string
& __str
)
261 { return this->assign(__str
); }
263 #if __cplusplus >= 201103L
265 * @brief String move assignment operator.
266 * @param __str Source string.
268 * The contents of @a __str are moved into this string (without
269 * copying). @a __str is a valid, but unspecified string.
272 operator=(__versa_string
&& __str
) noexcept
280 * @brief Set value to string constructed from initializer list.
281 * @param __l std::initializer_list.
284 operator=(std::initializer_list
<_CharT
> __l
)
286 this->assign(__l
.begin(), __l
.end());
292 * @brief Copy contents of @a __s into this string.
293 * @param __s Source null-terminated string.
296 operator=(const _CharT
* __s
)
297 { return this->assign(__s
); }
300 * @brief Set value to string of length 1.
301 * @param __c Source character.
303 * Assigning to a character makes this string length 1 and
304 * (*this)[0] == @a __c.
307 operator=(_CharT __c
)
309 this->assign(1, __c
);
315 * Returns a read/write iterator that points to the first character in
316 * the %string. Unshares the string.
319 begin() _GLIBCXX_NOEXCEPT
322 return iterator(this->_M_data());
326 * Returns a read-only (constant) iterator that points to the first
327 * character in the %string.
330 begin() const _GLIBCXX_NOEXCEPT
331 { return const_iterator(this->_M_data()); }
334 * Returns a read/write iterator that points one past the last
335 * character in the %string. Unshares the string.
338 end() _GLIBCXX_NOEXCEPT
341 return iterator(this->_M_data() + this->size());
345 * Returns a read-only (constant) iterator that points one past the
346 * last character in the %string.
349 end() const _GLIBCXX_NOEXCEPT
350 { return const_iterator(this->_M_data() + this->size()); }
353 * Returns a read/write reverse iterator that points to the last
354 * character in the %string. Iteration is done in reverse element
355 * order. Unshares the string.
358 rbegin() _GLIBCXX_NOEXCEPT
359 { return reverse_iterator(this->end()); }
362 * Returns a read-only (constant) reverse iterator that points
363 * to the last character in the %string. Iteration is done in
364 * reverse element order.
366 const_reverse_iterator
367 rbegin() const _GLIBCXX_NOEXCEPT
368 { return const_reverse_iterator(this->end()); }
371 * Returns a read/write reverse iterator that points to one before the
372 * first character in the %string. Iteration is done in reverse
373 * element order. Unshares the string.
376 rend() _GLIBCXX_NOEXCEPT
377 { return reverse_iterator(this->begin()); }
380 * Returns a read-only (constant) reverse iterator that points
381 * to one before the first character in the %string. Iteration
382 * is done in reverse element order.
384 const_reverse_iterator
385 rend() const _GLIBCXX_NOEXCEPT
386 { return const_reverse_iterator(this->begin()); }
388 #if __cplusplus >= 201103L
390 * Returns a read-only (constant) iterator that points to the first
391 * character in the %string.
394 cbegin() const noexcept
395 { return const_iterator(this->_M_data()); }
398 * Returns a read-only (constant) iterator that points one past the
399 * last character in the %string.
402 cend() const noexcept
403 { return const_iterator(this->_M_data() + this->size()); }
406 * Returns a read-only (constant) reverse iterator that points
407 * to the last character in the %string. Iteration is done in
408 * reverse element order.
410 const_reverse_iterator
411 crbegin() const noexcept
412 { return const_reverse_iterator(this->end()); }
415 * Returns a read-only (constant) reverse iterator that points
416 * to one before the first character in the %string. Iteration
417 * is done in reverse element order.
419 const_reverse_iterator
420 crend() const noexcept
421 { return const_reverse_iterator(this->begin()); }
426 /// Returns the number of characters in the string, not including any
427 /// null-termination.
429 size() const _GLIBCXX_NOEXCEPT
430 { return this->_M_length(); }
432 /// Returns the number of characters in the string, not including any
433 /// null-termination.
435 length() const _GLIBCXX_NOEXCEPT
436 { return this->_M_length(); }
438 /// Returns the size() of the largest possible %string.
440 max_size() const _GLIBCXX_NOEXCEPT
441 { return this->_M_max_size(); }
444 * @brief Resizes the %string to the specified number of characters.
445 * @param __n Number of characters the %string should contain.
446 * @param __c Character to fill any new elements.
448 * This function will %resize the %string to the specified
449 * number of characters. If the number is smaller than the
450 * %string's current size the %string is truncated, otherwise
451 * the %string is extended and new elements are set to @a __c.
454 resize(size_type __n
, _CharT __c
);
457 * @brief Resizes the %string to the specified number of characters.
458 * @param __n Number of characters the %string should contain.
460 * This function will resize the %string to the specified
461 * length. If the new size is smaller than the %string's
462 * current size the %string is truncated, otherwise the %string
463 * is extended and new characters are default-constructed. For
464 * basic types such as char, this means setting them to 0.
467 resize(size_type __n
)
468 { this->resize(__n
, _CharT()); }
470 #if __cplusplus >= 201103L
471 /// A non-binding request to reduce capacity() to size().
473 shrink_to_fit() noexcept
475 if (capacity() > size())
478 { this->reserve(0); }
486 * Returns the total number of characters that the %string can
487 * hold before needing to allocate more memory.
490 capacity() const _GLIBCXX_NOEXCEPT
491 { return this->_M_capacity(); }
494 * @brief Attempt to preallocate enough memory for specified number of
496 * @param __res_arg Number of characters required.
497 * @throw std::length_error If @a __res_arg exceeds @c max_size().
499 * This function attempts to reserve enough memory for the
500 * %string to hold the specified number of characters. If the
501 * number requested is more than max_size(), length_error is
504 * The advantage of this function is that if optimal code is a
505 * necessity and the user can determine the string length that
506 * will be required, the user can reserve the memory in
507 * %advance, and thus prevent a possible reallocation of memory
508 * and copying of %string data.
511 reserve(size_type __res_arg
= 0)
512 { this->_M_reserve(__res_arg
); }
515 * Erases the string, making it empty.
518 clear() _GLIBCXX_NOEXCEPT
519 { this->_M_clear(); }
522 * Returns true if the %string is empty. Equivalent to
523 * <code>*this == ""</code>.
525 _GLIBCXX_NODISCARD
bool
526 empty() const _GLIBCXX_NOEXCEPT
527 { return this->size() == 0; }
531 * @brief Subscript access to the data contained in the %string.
532 * @param __pos The index of the character to access.
533 * @return Read-only (constant) reference to the character.
535 * This operator allows for easy, array-style, data access.
536 * Note that data access with this operator is unchecked and
537 * out_of_range lookups are not defined. (For checked lookups
541 operator[] (size_type __pos
) const _GLIBCXX_NOEXCEPT
543 __glibcxx_assert(__pos
<= this->size());
544 return this->_M_data()[__pos
];
548 * @brief Subscript access to the data contained in the %string.
549 * @param __pos The index of the character to access.
550 * @return Read/write reference to the character.
552 * This operator allows for easy, array-style, data access.
553 * Note that data access with this operator is unchecked and
554 * out_of_range lookups are not defined. (For checked lookups
555 * see at().) Unshares the string.
558 operator[](size_type __pos
) _GLIBCXX_NOEXCEPT
560 // Allow pos == size() both in C++98 mode, as v3 extension,
561 // and in C++11 mode.
562 __glibcxx_assert(__pos
<= this->size());
563 // In pedantic mode be strict in C++98 mode.
564 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus
>= 201103L
565 || __pos
< this->size());
567 return this->_M_data()[__pos
];
571 * @brief Provides access to the data contained in the %string.
572 * @param __n The index of the character to access.
573 * @return Read-only (const) reference to the character.
574 * @throw std::out_of_range If @a __n is an invalid index.
576 * This function provides for safer data access. The parameter
577 * is first checked that it is in the range of the string. The
578 * function throws out_of_range if the check fails.
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
];
592 * @brief Provides access to the data contained in the %string.
593 * @param __n The index of the character to access.
594 * @return Read/write reference to the character.
595 * @throw std::out_of_range If @a __n is an invalid index.
597 * This function provides for safer data access. The parameter
598 * is first checked that it is in the range of the string. The
599 * function throws out_of_range if the check fails. Success
600 * results in unsharing the string.
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
616 * Returns a read/write reference to the data at the first
617 * element of the %string.
621 { return operator[](0); }
624 * Returns a read-only (constant) reference to the data at the first
625 * element of the %string.
628 front() const noexcept
629 { return operator[](0); }
632 * Returns a read/write reference to the data at the last
633 * element of the %string.
637 { return operator[](this->size() - 1); }
640 * Returns a read-only (constant) reference to the data at the
641 * last element of the %string.
644 back() const noexcept
645 { return operator[](this->size() - 1); }
650 * @brief Append a string to this string.
651 * @param __str The string to append.
652 * @return Reference to this string.
655 operator+=(const __versa_string
& __str
)
656 { return this->append(__str
); }
659 * @brief Append a C string.
660 * @param __s The C string to append.
661 * @return Reference to this string.
664 operator+=(const _CharT
* __s
)
665 { return this->append(__s
); }
668 * @brief Append a character.
669 * @param __c The character to append.
670 * @return Reference to this string.
673 operator+=(_CharT __c
)
675 this->push_back(__c
);
679 #if __cplusplus >= 201103L
681 * @brief Append an initializer_list of characters.
682 * @param __l The initializer_list of characters to be appended.
683 * @return Reference to this string.
686 operator+=(std::initializer_list
<_CharT
> __l
)
687 { return this->append(__l
.begin(), __l
.end()); }
691 * @brief Append a string to this string.
692 * @param __str The string to append.
693 * @return Reference to this string.
696 append(const __versa_string
& __str
)
697 { return _M_append(__str
._M_data(), __str
.size()); }
700 * @brief Append a substring.
701 * @param __str The string to append.
702 * @param __pos Index of the first character of str to append.
703 * @param __n The number of characters to append.
704 * @return Reference to this string.
705 * @throw std::out_of_range if @a pos is not a valid index.
707 * This function appends @a __n characters from @a __str
708 * starting at @a __pos to this string. If @a __n is is larger
709 * than the number of available characters in @a __str, the
710 * remainder of @a __str is appended.
713 append(const __versa_string
& __str
, size_type __pos
, size_type __n
)
714 { return _M_append(__str
._M_data()
715 + __str
._M_check(__pos
, "__versa_string::append"),
716 __str
._M_limit(__pos
, __n
)); }
719 * @brief Append a C substring.
720 * @param __s The C string to append.
721 * @param __n The number of characters to append.
722 * @return Reference to this string.
725 append(const _CharT
* __s
, size_type __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
);
733 * @brief Append a C string.
734 * @param __s The C string to append.
735 * @return Reference to this string.
738 append(const _CharT
* __s
)
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
);
747 * @brief Append multiple characters.
748 * @param __n The number of characters to append.
749 * @param __c The character to use.
750 * @return Reference to this string.
752 * Appends n copies of c to this string.
755 append(size_type __n
, _CharT __c
)
756 { return _M_replace_aux(this->size(), size_type(0), __n
, __c
); }
758 #if __cplusplus >= 201103L
760 * @brief Append an initializer_list of characters.
761 * @param __l The initializer_list of characters to append.
762 * @return Reference to this string.
765 append(std::initializer_list
<_CharT
> __l
)
766 { return this->append(__l
.begin(), __l
.end()); }
770 * @brief Append a range of characters.
771 * @param __first Iterator referencing the first character to append.
772 * @param __last Iterator marking the end of the range.
773 * @return Reference to this string.
775 * Appends characters in the range [first,last) to this string.
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
); }
788 * @brief Append a single character.
789 * @param __c Character to append.
792 push_back(_CharT __c
)
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);
802 * @brief Set value to contents of another string.
803 * @param __str Source string to use.
804 * @return Reference to this string.
807 assign(const __versa_string
& __str
)
809 this->_M_assign(__str
);
813 #if __cplusplus >= 201103L
815 * @brief Set value to contents of another string.
816 * @param __str Source string to use.
817 * @return Reference to this string.
819 * This function sets this string to the exact contents of @a __str.
820 * @a __str is a valid, but unspecified string.
823 assign(__versa_string
&& __str
) noexcept
831 * @brief Set value to a substring of a string.
832 * @param __str The string to use.
833 * @param __pos Index of the first character of str.
834 * @param __n Number of characters to use.
835 * @return Reference to this string.
836 * @throw std::out_of_range if @a __pos is not a valid index.
838 * This function sets this string to the substring of @a __str
839 * consisting of @a __n characters at @a __pos. If @a __n is
840 * is larger than the number of available characters in @a
841 * __str, the remainder of @a __str is used.
844 assign(const __versa_string
& __str
, size_type __pos
, size_type __n
)
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
)); }
850 * @brief Set value to a C substring.
851 * @param __s The C string to use.
852 * @param __n Number of characters to use.
853 * @return Reference to this string.
855 * This function sets the value of this string to the first @a
856 * __n characters of @a __s. If @a __n is is larger than the
857 * number of available characters in @a __s, the remainder of
861 assign(const _CharT
* __s
, size_type __n
)
863 __glibcxx_requires_string_len(__s
, __n
);
864 return _M_replace(size_type(0), this->size(), __s
, __n
);
868 * @brief Set value to contents of a C string.
869 * @param __s The C string to use.
870 * @return Reference to this string.
872 * This function sets the value of this string to the value of
873 * @a __s. The data is copied, so there is no dependence on @a
874 * __s once the function returns.
877 assign(const _CharT
* __s
)
879 __glibcxx_requires_string(__s
);
880 return _M_replace(size_type(0), this->size(), __s
,
881 traits_type::length(__s
));
885 * @brief Set value to multiple characters.
886 * @param __n Length of the resulting string.
887 * @param __c The character to use.
888 * @return Reference to this string.
890 * This function sets the value of this string to @a __n copies of
894 assign(size_type __n
, _CharT __c
)
895 { return _M_replace_aux(size_type(0), this->size(), __n
, __c
); }
898 * @brief Set value to a range of characters.
899 * @param __first Iterator referencing the first character to append.
900 * @param __last Iterator marking the end of the range.
901 * @return Reference to this string.
903 * Sets value of string to characters in the range
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
918 * @brief Set value to an initializer_list of characters.
919 * @param __l The initializer_list of characters to assign.
920 * @return Reference to this string.
923 assign(std::initializer_list
<_CharT
> __l
)
924 { return this->assign(__l
.begin(), __l
.end()); }
927 #if __cplusplus >= 201103L
929 * @brief Insert multiple characters.
930 * @param __p Const_iterator referencing location in string to
932 * @param __n Number of characters to insert
933 * @param __c The character to insert.
934 * @return Iterator referencing the first inserted char.
935 * @throw std::length_error If new length exceeds @c max_size().
937 * Inserts @a __n copies of character @a __c starting at the
938 * position referenced by iterator @a __p. If adding
939 * characters causes the length to exceed max_size(),
940 * length_error is thrown. The value of the string doesn't
941 * change if an error is thrown.
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
);
953 * @brief Insert multiple characters.
954 * @param __p Iterator referencing location in string to insert at.
955 * @param __n Number of characters to insert
956 * @param __c The character to insert.
957 * @throw std::length_error If new length exceeds @c max_size().
959 * Inserts @a __n copies of character @a __c starting at the
960 * position referenced by iterator @a __p. If adding
961 * characters causes the length to exceed max_size(),
962 * length_error is thrown. The value of the string doesn't
963 * change if an error is thrown.
966 insert(iterator __p
, size_type __n
, _CharT __c
)
967 { this->replace(__p
, __p
, __n
, __c
); }
970 #if __cplusplus >= 201103L
972 * @brief Insert a range of characters.
973 * @param __p Const_iterator referencing location in string to
975 * @param __beg Start of range.
976 * @param __end End of range.
977 * @return Iterator referencing the first inserted char.
978 * @throw std::length_error If new length exceeds @c max_size().
980 * Inserts characters in range [beg,end). If adding characters
981 * causes the length to exceed max_size(), length_error is
982 * thrown. The value of the string doesn't change if an error
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
);
997 * @brief Insert a range of characters.
998 * @param __p Iterator referencing location in string to insert at.
999 * @param __beg Start of range.
1000 * @param __end End of range.
1001 * @throw std::length_error If new length exceeds @c max_size().
1003 * Inserts characters in range [beg,end). If adding characters
1004 * causes the length to exceed max_size(), length_error is
1005 * thrown. The value of the string doesn't change if an error
1008 template<class _InputIterator
>
1010 insert(iterator __p
, _InputIterator __beg
, _InputIterator __end
)
1011 { this->replace(__p
, __p
, __beg
, __end
); }
1014 #if __cplusplus >= 201103L
1016 * @brief Insert an initializer_list of characters.
1017 * @param __p Const_iterator referencing location in string to
1019 * @param __l The initializer_list of characters to insert.
1020 * @return Iterator referencing the first inserted char.
1021 * @throw std::length_error If new length exceeds @c max_size().
1024 insert(const_iterator __p
, std::initializer_list
<_CharT
> __l
)
1025 { return this->insert(__p
, __l
.begin(), __l
.end()); }
1029 * @brief Insert value of a string.
1030 * @param __pos1 Iterator referencing location in string to insert at.
1031 * @param __str The string to insert.
1032 * @return Reference to this string.
1033 * @throw std::length_error If new length exceeds @c max_size().
1035 * Inserts value of @a __str starting at @a __pos1. If adding
1036 * characters causes the length to exceed max_size(),
1037 * length_error is thrown. The value of the string doesn't
1038 * change if an error is thrown.
1041 insert(size_type __pos1
, const __versa_string
& __str
)
1042 { return this->replace(__pos1
, size_type(0),
1043 __str
._M_data(), __str
.size()); }
1046 * @brief Insert a substring.
1047 * @param __pos1 Iterator referencing location in string to insert at.
1048 * @param __str The string to insert.
1049 * @param __pos2 Start of characters in str to insert.
1050 * @param __n Number of characters to insert.
1051 * @return Reference to this string.
1052 * @throw std::length_error If new length exceeds @c max_size().
1053 * @throw std::out_of_range If @a __pos1 > size() or
1054 * @a __pos2 > @a __str.size().
1056 * Starting at @a __pos1, insert @a __n character of @a __str
1057 * beginning with @a __pos2. If adding characters causes the
1058 * length to exceed max_size(), length_error is thrown. If @a
1059 * __pos1 is beyond the end of this string or @a __pos2 is
1060 * beyond the end of @a __str, out_of_range is thrown. The
1061 * value of the string doesn't change if an error is thrown.
1064 insert(size_type __pos1
, const __versa_string
& __str
,
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
)); }
1071 * @brief Insert a C substring.
1072 * @param __pos Iterator referencing location in string to insert at.
1073 * @param __s The C string to insert.
1074 * @param __n The number of characters to insert.
1075 * @return Reference to this string.
1076 * @throw std::length_error If new length exceeds @c max_size().
1077 * @throw std::out_of_range If @a __pos is beyond the end of this
1080 * Inserts the first @a __n characters of @a __s starting at @a
1081 * __pos. If adding characters causes the length to exceed
1082 * max_size(), length_error is thrown. If @a __pos is beyond
1083 * end(), out_of_range is thrown. The value of the string
1084 * doesn't change if an error is thrown.
1087 insert(size_type __pos
, const _CharT
* __s
, size_type __n
)
1088 { return this->replace(__pos
, size_type(0), __s
, __n
); }
1091 * @brief Insert a C string.
1092 * @param __pos Iterator referencing location in string to insert at.
1093 * @param __s The C string to insert.
1094 * @return Reference to this string.
1095 * @throw std::length_error If new length exceeds @c max_size().
1096 * @throw std::out_of_range If @a __pos is beyond the end of this
1099 * Inserts the first @a __n characters of @a __s starting at @a
1100 * __pos. If adding characters causes the length to exceed
1101 * max_size(), length_error is thrown. If @a __pos is beyond
1102 * end(), out_of_range is thrown. The value of the string
1103 * doesn't change if an error is thrown.
1106 insert(size_type __pos
, const _CharT
* __s
)
1108 __glibcxx_requires_string(__s
);
1109 return this->replace(__pos
, size_type(0), __s
,
1110 traits_type::length(__s
));
1114 * @brief Insert multiple characters.
1115 * @param __pos Index in string to insert at.
1116 * @param __n Number of characters to insert
1117 * @param __c The character to insert.
1118 * @return Reference to this string.
1119 * @throw std::length_error If new length exceeds @c max_size().
1120 * @throw std::out_of_range If @a __pos is beyond the end of this
1123 * Inserts @a __n copies of character @a __c starting at index
1124 * @a __pos. If adding characters causes the length to exceed
1125 * max_size(), length_error is thrown. If @a __pos > length(),
1126 * out_of_range is thrown. The value of the string doesn't
1127 * change if an error is thrown.
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
); }
1135 * @brief Insert one character.
1136 * @param __p Iterator referencing position in string to insert at.
1137 * @param __c The character to insert.
1138 * @return Iterator referencing newly inserted char.
1139 * @throw std::length_error If new length exceeds @c max_size().
1141 * Inserts character @a __c at position referenced by @a __p.
1142 * If adding character causes the length to exceed max_size(),
1143 * length_error is thrown. If @a __p is beyond end of string,
1144 * out_of_range is thrown. The value of the string doesn't
1145 * change if an error is thrown.
1148 #if __cplusplus >= 201103L
1149 insert(const_iterator __p
, _CharT __c
)
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
);
1162 * @brief Remove characters.
1163 * @param __pos Index of first character to remove (default 0).
1164 * @param __n Number of characters to remove (default remainder).
1165 * @return Reference to this string.
1166 * @throw std::out_of_range If @a __pos is beyond the end of this
1169 * Removes @a __n characters from this string starting at @a
1170 * __pos. The length of the string is reduced by @a __n. If
1171 * there are < @a __n characters to remove, the remainder of
1172 * the string is truncated. If @a __p is beyond end of string,
1173 * out_of_range is thrown. The value of the string doesn't
1174 * change if an error is thrown.
1177 erase(size_type __pos
= 0, size_type __n
= npos
)
1179 this->_M_erase(_M_check(__pos
, "__versa_string::erase"),
1180 _M_limit(__pos
, __n
));
1185 * @brief Remove one character.
1186 * @param __position Iterator referencing the character to remove.
1187 * @return iterator referencing same location after removal.
1189 * Removes the character at @a __position from this string. The
1190 * value of the string doesn't change if an error is thrown.
1193 #if __cplusplus >= 201103L
1194 erase(const_iterator __position
)
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
);
1208 * @brief Remove a range of characters.
1209 * @param __first Iterator referencing the first character to remove.
1210 * @param __last Iterator referencing the end of the range.
1211 * @return Iterator referencing location of first after removal.
1213 * Removes the characters in the range [first,last) from this
1214 * string. The value of the string doesn't change if an error
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
1234 * @brief Remove the last character.
1236 * The string must be non-empty.
1240 { this->_M_erase(size()-1, 1); }
1244 * @brief Replace characters with value from another string.
1245 * @param __pos Index of first character to replace.
1246 * @param __n Number of characters to be replaced.
1247 * @param __str String to insert.
1248 * @return Reference to this string.
1249 * @throw std::out_of_range If @a __pos is beyond the end of this
1251 * @throw std::length_error If new length exceeds @c max_size().
1253 * Removes the characters in the range [pos,pos+n) from this
1254 * string. In place, the value of @a __str is inserted. If @a
1255 * __pos is beyond end of string, out_of_range is thrown. If
1256 * the length of the result exceeds max_size(), length_error is
1257 * thrown. The value of the string doesn't change if an error
1261 replace(size_type __pos
, size_type __n
, const __versa_string
& __str
)
1262 { return this->replace(__pos
, __n
, __str
._M_data(), __str
.size()); }
1265 * @brief Replace characters with value from another string.
1266 * @param __pos1 Index of first character to replace.
1267 * @param __n1 Number of characters to be replaced.
1268 * @param __str String to insert.
1269 * @param __pos2 Index of first character of str to use.
1270 * @param __n2 Number of characters from str to use.
1271 * @return Reference to this string.
1272 * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 >
1274 * @throw std::length_error If new length exceeds @c max_size().
1276 * Removes the characters in the range [pos1,pos1 + n) from
1277 * this string. In place, the value of @a __str is inserted.
1278 * If @a __pos is beyond end of string, out_of_range is thrown.
1279 * If the length of the result exceeds max_size(), length_error
1280 * is thrown. The value of the string doesn't change if an
1284 replace(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
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
));
1294 * @brief Replace characters with value of a C substring.
1295 * @param __pos Index of first character to replace.
1296 * @param __n1 Number of characters to be replaced.
1297 * @param __s C string to insert.
1298 * @param __n2 Number of characters from @a __s to use.
1299 * @return Reference to this string.
1300 * @throw std::out_of_range If @a __pos1 > size().
1301 * @throw std::length_error If new length exceeds @c max_size().
1303 * Removes the characters in the range [pos,pos + n1) from this
1304 * string. In place, the first @a __n2 characters of @a __s
1305 * are inserted, or all of @a __s if @a __n2 is too large. If
1306 * @a __pos is beyond end of string, out_of_range is thrown.
1307 * If the length of result exceeds max_size(), length_error is
1308 * thrown. The value of the string doesn't change if an error
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
);
1321 * @brief Replace characters with value of a C string.
1322 * @param __pos Index of first character to replace.
1323 * @param __n1 Number of characters to be replaced.
1324 * @param __s C string to insert.
1325 * @return Reference to this string.
1326 * @throw std::out_of_range If @a __pos > size().
1327 * @throw std::length_error If new length exceeds @c max_size().
1329 * Removes the characters in the range [pos,pos + n1) from this
1330 * string. In place, the characters of @a __s are inserted. If
1331 * @a pos is beyond end of string, out_of_range is thrown. If
1332 * the length of result exceeds max_size(), length_error is thrown.
1333 * The value of the string doesn't change if an error is thrown.
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
));
1343 * @brief Replace characters with multiple characters.
1344 * @param __pos Index of first character to replace.
1345 * @param __n1 Number of characters to be replaced.
1346 * @param __n2 Number of characters to insert.
1347 * @param __c Character to insert.
1348 * @return Reference to this string.
1349 * @throw std::out_of_range If @a __pos > size().
1350 * @throw std::length_error If new length exceeds @c max_size().
1352 * Removes the characters in the range [pos,pos + n1) from this
1353 * string. In place, @a __n2 copies of @a __c are inserted.
1354 * If @a __pos is beyond end of string, out_of_range is thrown.
1355 * If the length of result exceeds max_size(), length_error is
1356 * thrown. The value of the string doesn't change if an error
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
); }
1365 * @brief Replace range of characters with string.
1366 * @param __i1 Iterator referencing start of range to replace.
1367 * @param __i2 Iterator referencing end of range to replace.
1368 * @param __str String value to insert.
1369 * @return Reference to this string.
1370 * @throw std::length_error If new length exceeds @c max_size().
1372 * Removes the characters in the range [i1,i2). In place, the
1373 * value of @a __str is inserted. If the length of result
1374 * exceeds max_size(), length_error is thrown. The value of
1375 * the string doesn't change if an error is thrown.
1378 #if __cplusplus >= 201103L
1379 replace(const_iterator __i1
, const_iterator __i2
,
1380 const __versa_string
& __str
)
1382 replace(iterator __i1
, iterator __i2
, const __versa_string
& __str
)
1384 { return this->replace(__i1
, __i2
, __str
._M_data(), __str
.size()); }
1387 * @brief Replace range of characters with C substring.
1388 * @param __i1 Iterator referencing start of range to replace.
1389 * @param __i2 Iterator referencing end of range to replace.
1390 * @param __s C string value to insert.
1391 * @param __n Number of characters from s to insert.
1392 * @return Reference to this string.
1393 * @throw std::length_error If new length exceeds @c max_size().
1395 * Removes the characters in the range [i1,i2). In place, the
1396 * first @a n characters of @a __s are inserted. If the length
1397 * of result exceeds max_size(), length_error is thrown. The
1398 * value of the string doesn't change if an error is thrown.
1401 #if __cplusplus >= 201103L
1402 replace(const_iterator __i1
, const_iterator __i2
,
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
);
1414 * @brief Replace range of characters with C string.
1415 * @param __i1 Iterator referencing start of range to replace.
1416 * @param __i2 Iterator referencing end of range to replace.
1417 * @param __s C string value to insert.
1418 * @return Reference to this string.
1419 * @throw std::length_error If new length exceeds @c max_size().
1421 * Removes the characters in the range [i1,i2). In place, the
1422 * characters of @a __s are inserted. If the length of result
1423 * exceeds max_size(), length_error is thrown. The value of
1424 * the string doesn't change if an error is thrown.
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
));
1438 * @brief Replace range of characters with multiple characters
1439 * @param __i1 Iterator referencing start of range to replace.
1440 * @param __i2 Iterator referencing end of range to replace.
1441 * @param __n Number of characters to insert.
1442 * @param __c Character to insert.
1443 * @return Reference to this string.
1444 * @throw std::length_error If new length exceeds @c max_size().
1446 * Removes the characters in the range [i1,i2). In place, @a
1447 * __n copies of @a __c are inserted. If the length of result
1448 * exceeds max_size(), length_error is thrown. The value of
1449 * the string doesn't change if an error is thrown.
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
);
1465 * @brief Replace range of characters with range.
1466 * @param __i1 Iterator referencing start of range to replace.
1467 * @param __i2 Iterator referencing end of range to replace.
1468 * @param __k1 Iterator referencing start of range to insert.
1469 * @param __k2 Iterator referencing end of range to insert.
1470 * @return Reference to this string.
1471 * @throw std::length_error If new length exceeds @c max_size().
1473 * Removes the characters in the range [i1,i2). In place,
1474 * characters in the range [k1,k2) are inserted. If the length
1475 * of result exceeds max_size(), length_error is thrown. The
1476 * value of the string doesn't change if an error is thrown.
1478 #if __cplusplus >= 201103L
1479 template<class _InputIterator
,
1480 typename
= std::_RequireInputIter
<_InputIterator
>>
1482 replace(const_iterator __i1
, const_iterator __i2
,
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());
1505 // Specializations for the common case of pointer and iterator:
1506 // useful to avoid the overhead of temporary buffering in _M_replace.
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
1573 * @brief Replace range of characters with initializer_list.
1574 * @param __i1 Iterator referencing start of range to replace.
1575 * @param __i2 Iterator referencing end of range to replace.
1576 * @param __l The initializer_list of characters to insert.
1577 * @return Reference to this string.
1578 * @throw std::length_error If new length exceeds @c max_size().
1580 * Removes the characters in the range [i1,i2). In place,
1581 * characters in the range [k1,k2) are inserted. If the length
1582 * of result exceeds max_size(), length_error is thrown. The
1583 * value of the string doesn't change if an error is thrown.
1586 replace(const_iterator __i1
, const_iterator __i2
,
1587 std::initializer_list
<_CharT
> __l
)
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
);
1618 * @brief Copy substring into C string.
1619 * @param __s C string to copy value into.
1620 * @param __n Number of characters to copy.
1621 * @param __pos Index of first character to copy.
1622 * @return Number of characters actually copied
1623 * @throw std::out_of_range If pos > size().
1625 * Copies up to @a __n characters starting at @a __pos into the
1626 * C string @a s. If @a __pos is greater than size(),
1627 * out_of_range is thrown.
1630 copy(_CharT
* __s
, size_type __n
, size_type __pos
= 0) const;
1633 * @brief Swap contents with another string.
1634 * @param __s String to swap with.
1636 * Exchanges the contents of this string with that of @a __s in
1640 swap(__versa_string
& __s
) _GLIBCXX_NOEXCEPT
1641 { this->_M_swap(__s
); }
1643 // String operations:
1645 * @brief Return const pointer to null-terminated contents.
1647 * This is a handle to internal data. Do not modify or dire things may
1651 c_str() const _GLIBCXX_NOEXCEPT
1652 { return this->_M_data(); }
1655 * @brief Return const pointer to contents.
1657 * This is a handle to internal data. Do not modify or dire things may
1661 data() const _GLIBCXX_NOEXCEPT
1662 { return this->_M_data(); }
1665 * @brief Return copy of allocator used to construct this string.
1668 get_allocator() const _GLIBCXX_NOEXCEPT
1669 { return allocator_type(this->_M_get_allocator()); }
1672 * @brief Find position of a C substring.
1673 * @param __s C string to locate.
1674 * @param __pos Index of character to search from.
1675 * @param __n Number of characters from @a __s to search for.
1676 * @return Index of start of first occurrence.
1678 * Starting from @a __pos, searches forward for the first @a
1679 * __n characters in @a __s within this string. If found,
1680 * returns the index where it begins. If not found, returns
1684 find(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1687 * @brief Find position of a string.
1688 * @param __str String to locate.
1689 * @param __pos Index of character to search from (default 0).
1690 * @return Index of start of first occurrence.
1692 * Starting from @a __pos, searches forward for value of @a
1693 * __str within this string. If found, returns the index where
1694 * it begins. If not found, returns npos.
1697 find(const __versa_string
& __str
, size_type __pos
= 0) const
1699 { return this->find(__str
.data(), __pos
, __str
.size()); }
1702 * @brief Find position of a C string.
1703 * @param __s C string to locate.
1704 * @param __pos Index of character to search from (default 0).
1705 * @return Index of start of first occurrence.
1707 * Starting from @a __pos, searches forward for the value of @a
1708 * __s within this string. If found, returns the index where
1709 * it begins. If not found, returns npos.
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
));
1719 * @brief Find position of a character.
1720 * @param __c Character to locate.
1721 * @param __pos Index of character to search from (default 0).
1722 * @return Index of first occurrence.
1724 * Starting from @a __pos, searches forward for @a __c within
1725 * this string. If found, returns the index where it was
1726 * found. If not found, returns npos.
1729 find(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
;
1732 * @brief Find last position of a string.
1733 * @param __str String to locate.
1734 * @param __pos Index of character to search back from (default end).
1735 * @return Index of start of last occurrence.
1737 * Starting from @a __pos, searches backward for value of @a
1738 * __str within this string. If found, returns the index where
1739 * it begins. If not found, returns npos.
1742 rfind(const __versa_string
& __str
, size_type __pos
= npos
) const
1744 { return this->rfind(__str
.data(), __pos
, __str
.size()); }
1747 * @brief Find last position of a C substring.
1748 * @param __s C string to locate.
1749 * @param __pos Index of character to search back from.
1750 * @param __n Number of characters from s to search for.
1751 * @return Index of start of last occurrence.
1753 * Starting from @a __pos, searches backward for the first @a
1754 * __n characters in @a __s within this string. If found,
1755 * returns the index where it begins. If not found, returns
1759 rfind(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1762 * @brief Find last position of a C string.
1763 * @param __s C string to locate.
1764 * @param __pos Index of character to start search at (default end).
1765 * @return Index of start of last occurrence.
1767 * Starting from @a __pos, searches backward for the value of
1768 * @a __s within this string. If found, returns the index
1769 * where it begins. If not found, returns npos.
1772 rfind(const _CharT
* __s
, size_type __pos
= npos
) const
1774 __glibcxx_requires_string(__s
);
1775 return this->rfind(__s
, __pos
, traits_type::length(__s
));
1779 * @brief Find last position of a character.
1780 * @param __c Character to locate.
1781 * @param __pos Index of character to search back from (default end).
1782 * @return Index of last occurrence.
1784 * Starting from @a __pos, searches backward for @a __c within
1785 * this string. If found, returns the index where it was
1786 * found. If not found, returns npos.
1789 rfind(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
;
1792 * @brief Find position of a character of string.
1793 * @param __str String containing characters to locate.
1794 * @param __pos Index of character to search from (default 0).
1795 * @return Index of first occurrence.
1797 * Starting from @a __pos, searches forward for one of the characters of
1798 * @a __str within this string. If found, returns the index where it was
1799 * found. If not found, returns npos.
1802 find_first_of(const __versa_string
& __str
, size_type __pos
= 0) const
1804 { return this->find_first_of(__str
.data(), __pos
, __str
.size()); }
1807 * @brief Find position of a character of C substring.
1808 * @param __s String containing characters to locate.
1809 * @param __pos Index of character to search from.
1810 * @param __n Number of characters from s to search for.
1811 * @return Index of first occurrence.
1813 * Starting from @a __pos, searches forward for one of the
1814 * first @a __n characters of @a __s within this string. If
1815 * found, returns the index where it was found. If not found,
1819 find_first_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1822 * @brief Find position of a character of C string.
1823 * @param __s String containing characters to locate.
1824 * @param __pos Index of character to search from (default 0).
1825 * @return Index of first occurrence.
1827 * Starting from @a __pos, searches forward for one of the
1828 * characters of @a __s within this string. If found, returns
1829 * the index where it was found. If not found, returns npos.
1832 find_first_of(const _CharT
* __s
, size_type __pos
= 0) const
1834 __glibcxx_requires_string(__s
);
1835 return this->find_first_of(__s
, __pos
, traits_type::length(__s
));
1839 * @brief Find position of a character.
1840 * @param __c Character to locate.
1841 * @param __pos Index of character to search from (default 0).
1842 * @return Index of first occurrence.
1844 * Starting from @a __pos, searches forward for the character
1845 * @a __c within this string. If found, returns the index
1846 * where it was found. If not found, returns npos.
1848 * Note: equivalent to find(c, pos).
1851 find_first_of(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
1852 { return this->find(__c
, __pos
); }
1855 * @brief Find last position of a character of string.
1856 * @param __str String containing characters to locate.
1857 * @param __pos Index of character to search back from (default end).
1858 * @return Index of last occurrence.
1860 * Starting from @a __pos, searches backward for one of the
1861 * characters of @a __str within this string. If found,
1862 * returns the index where it was found. If not found, returns
1866 find_last_of(const __versa_string
& __str
, size_type __pos
= npos
) const
1868 { return this->find_last_of(__str
.data(), __pos
, __str
.size()); }
1871 * @brief Find last position of a character of C substring.
1872 * @param __s C string containing characters to locate.
1873 * @param __pos Index of character to search back from.
1874 * @param __n Number of characters from s to search for.
1875 * @return Index of last occurrence.
1877 * Starting from @a __pos, searches backward for one of the
1878 * first @a __n characters of @a __s within this string. If
1879 * found, returns the index where it was found. If not found,
1883 find_last_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1886 * @brief Find last position of a character of C string.
1887 * @param __s C string containing characters to locate.
1888 * @param __pos Index of character to search back from (default end).
1889 * @return Index of last occurrence.
1891 * Starting from @a __pos, searches backward for one of the
1892 * characters of @a __s within this string. If found, returns
1893 * the index where it was found. If not found, returns npos.
1896 find_last_of(const _CharT
* __s
, size_type __pos
= npos
) const
1898 __glibcxx_requires_string(__s
);
1899 return this->find_last_of(__s
, __pos
, traits_type::length(__s
));
1903 * @brief Find last position of a character.
1904 * @param __c Character to locate.
1905 * @param __pos Index of character to search back from (default end).
1906 * @return Index of last occurrence.
1908 * Starting from @a __pos, searches backward for @a __c within
1909 * this string. If found, returns the index where it was
1910 * found. If not found, returns npos.
1912 * Note: equivalent to rfind(c, pos).
1915 find_last_of(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1916 { return this->rfind(__c
, __pos
); }
1919 * @brief Find position of a character not in string.
1920 * @param __str String containing characters to avoid.
1921 * @param __pos Index of character to search from (default 0).
1922 * @return Index of first occurrence.
1924 * Starting from @a __pos, searches forward for a character not
1925 * contained in @a __str within this string. If found, returns
1926 * the index where it was found. If not found, returns npos.
1929 find_first_not_of(const __versa_string
& __str
, size_type __pos
= 0) const
1931 { return this->find_first_not_of(__str
.data(), __pos
, __str
.size()); }
1934 * @brief Find position of a character not in C substring.
1935 * @param __s C string containing characters to avoid.
1936 * @param __pos Index of character to search from.
1937 * @param __n Number of characters from s to consider.
1938 * @return Index of first occurrence.
1940 * Starting from @a __pos, searches forward for a character not
1941 * contained in the first @a __n characters of @a __s within
1942 * this string. If found, returns the index where it was
1943 * found. If not found, returns npos.
1946 find_first_not_of(const _CharT
* __s
, size_type __pos
,
1947 size_type __n
) const;
1950 * @brief Find position of a character not in C string.
1951 * @param __s C string containing characters to avoid.
1952 * @param __pos Index of character to search from (default 0).
1953 * @return Index of first occurrence.
1955 * Starting from @a __pos, searches forward for a character not
1956 * contained in @a __s within this string. If found, returns
1957 * the index where it was found. If not found, returns npos.
1960 find_first_not_of(const _CharT
* __s
, size_type __pos
= 0) const
1962 __glibcxx_requires_string(__s
);
1963 return this->find_first_not_of(__s
, __pos
, traits_type::length(__s
));
1967 * @brief Find position of a different character.
1968 * @param __c Character to avoid.
1969 * @param __pos Index of character to search from (default 0).
1970 * @return Index of first occurrence.
1972 * Starting from @a __pos, searches forward for a character
1973 * other than @a __c within this string. If found, returns the
1974 * index where it was found. If not found, returns npos.
1977 find_first_not_of(_CharT __c
, size_type __pos
= 0) const
1981 * @brief Find last position of a character not in string.
1982 * @param __str String containing characters to avoid.
1983 * @param __pos Index of character to search back from (default end).
1984 * @return Index of last occurrence.
1986 * Starting from @a __pos, searches backward for a character
1987 * not contained in @a __str within this string. If found,
1988 * returns the index where it was found. If not found, returns
1992 find_last_not_of(const __versa_string
& __str
,
1993 size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1994 { return this->find_last_not_of(__str
.data(), __pos
, __str
.size()); }
1997 * @brief Find last position of a character not in C substring.
1998 * @param __s C string containing characters to avoid.
1999 * @param __pos Index of character to search back from.
2000 * @param __n Number of characters from s to consider.
2001 * @return Index of last occurrence.
2003 * Starting from @a __pos, searches backward for a character
2004 * not contained in the first @a __n characters of @a __s
2005 * within this string. If found, returns the index where it
2006 * was found. If not found, returns npos.
2009 find_last_not_of(const _CharT
* __s
, size_type __pos
,
2010 size_type __n
) const;
2012 * @brief Find last position of a character not in C string.
2013 * @param __s C string containing characters to avoid.
2014 * @param __pos Index of character to search back from (default end).
2015 * @return Index of last occurrence.
2017 * Starting from @a __pos, searches backward for a character
2018 * not contained in @a __s within this string. If found,
2019 * returns the index where it was found. If not found, returns
2023 find_last_not_of(const _CharT
* __s
, size_type __pos
= npos
) const
2025 __glibcxx_requires_string(__s
);
2026 return this->find_last_not_of(__s
, __pos
, traits_type::length(__s
));
2030 * @brief Find last position of a different character.
2031 * @param __c Character to avoid.
2032 * @param __pos Index of character to search back from (default end).
2033 * @return Index of last occurrence.
2035 * Starting from @a __pos, searches backward for a character
2036 * other than @a __c within this string. If found, returns the
2037 * index where it was found. If not found, returns npos.
2040 find_last_not_of(_CharT __c
, size_type __pos
= npos
) const
2044 * @brief Get a substring.
2045 * @param __pos Index of first character (default 0).
2046 * @param __n Number of characters in substring (default remainder).
2047 * @return The new string.
2048 * @throw std::out_of_range If pos > size().
2050 * Construct and return a new string using the @a __n
2051 * characters starting at @a __pos. If the string is too
2052 * short, use the remainder of the characters. If @a __pos is
2053 * beyond the end of the string, out_of_range is thrown.
2056 substr(size_type __pos
= 0, size_type __n
= npos
) const
2058 return __versa_string(*this, _M_check(__pos
, "__versa_string::substr"),
2063 * @brief Compare to a string.
2064 * @param __str String to compare against.
2065 * @return Integer < 0, 0, or > 0.
2067 * Returns an integer < 0 if this string is ordered before @a
2068 * __str, 0 if their values are equivalent, or > 0 if this
2069 * string is ordered after @a __str. Determines the effective
2070 * length rlen of the strings to compare as the smallest of
2071 * size() and str.size(). The function then compares the two
2072 * strings by calling traits::compare(data(), str.data(),rlen).
2073 * If the result of the comparison is nonzero returns it,
2074 * otherwise the shorter one is ordered first.
2077 compare(const __versa_string
& __str
) const
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
);
2093 * @brief Compare substring to a string.
2094 * @param __pos Index of first character of substring.
2095 * @param __n Number of characters in substring.
2096 * @param __str String to compare against.
2097 * @return Integer < 0, 0, or > 0.
2099 * Form the substring of this string from the @a __n characters
2100 * starting at @a __pos. Returns an integer < 0 if the
2101 * substring is ordered before @a __str, 0 if their values are
2102 * equivalent, or > 0 if the substring is ordered after @a
2103 * __str. Determines the effective length rlen of the strings
2104 * to compare as the smallest of the length of the substring
2105 * and @a __str.size(). The function then compares the two
2106 * strings by calling
2107 * traits::compare(substring.data(),str.data(),rlen). If the
2108 * result of the comparison is nonzero returns it, otherwise
2109 * the shorter one is ordered first.
2112 compare(size_type __pos
, size_type __n
,
2113 const __versa_string
& __str
) const;
2116 * @brief Compare substring to a substring.
2117 * @param __pos1 Index of first character of substring.
2118 * @param __n1 Number of characters in substring.
2119 * @param __str String to compare against.
2120 * @param __pos2 Index of first character of substring of str.
2121 * @param __n2 Number of characters in substring of str.
2122 * @return Integer < 0, 0, or > 0.
2124 * Form the substring of this string from the @a __n1
2125 * characters starting at @a __pos1. Form the substring of @a
2126 * __str from the @a __n2 characters starting at @a __pos2.
2127 * Returns an integer < 0 if this substring is ordered before
2128 * the substring of @a __str, 0 if their values are equivalent,
2129 * or > 0 if this substring is ordered after the substring of
2130 * @a __str. Determines the effective length rlen of the
2131 * strings to compare as the smallest of the lengths of the
2132 * substrings. The function then compares the two strings by
2134 * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
2135 * If the result of the comparison is nonzero returns it,
2136 * otherwise the shorter one is ordered first.
2139 compare(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
2140 size_type __pos2
, size_type __n2
) const;
2143 * @brief Compare to a C string.
2144 * @param __s C string to compare against.
2145 * @return Integer < 0, 0, or > 0.
2147 * Returns an integer < 0 if this string is ordered before @a
2148 * __s, 0 if their values are equivalent, or > 0 if this string
2149 * is ordered after @a __s. Determines the effective length
2150 * rlen of the strings to compare as the smallest of size() and
2151 * the length of a string constructed from @a __s. The
2152 * function then compares the two strings by calling
2153 * traits::compare(data(),s,rlen). If the result of the
2154 * comparison is nonzero returns it, otherwise the shorter one
2158 compare(const _CharT
* __s
) const;
2160 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2161 // 5 String::compare specification questionable
2163 * @brief Compare substring to a C string.
2164 * @param __pos Index of first character of substring.
2165 * @param __n1 Number of characters in substring.
2166 * @param __s C string to compare against.
2167 * @return Integer < 0, 0, or > 0.
2169 * Form the substring of this string from the @a __n1
2170 * characters starting at @a __pos. Returns an integer < 0 if
2171 * the substring is ordered before @a __s, 0 if their values
2172 * are equivalent, or > 0 if the substring is ordered after @a
2173 * __s. Determines the effective length rlen of the strings to
2174 * compare as the smallest of the length of the substring and
2175 * the length of a string constructed from @a __s. The
2176 * function then compares the two string by calling
2177 * traits::compare(substring.data(),s,rlen). If the result of
2178 * the comparison is nonzero returns it, otherwise the shorter
2179 * one is ordered first.
2182 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
) const;
2185 * @brief Compare substring against a character array.
2186 * @param __pos Index of first character of substring.
2187 * @param __n1 Number of characters in substring.
2188 * @param __s character array to compare against.
2189 * @param __n2 Number of characters of s.
2190 * @return Integer < 0, 0, or > 0.
2192 * Form the substring of this string from the @a __n1
2193 * characters starting at @a __pos. Form a string from the
2194 * first @a __n2 characters of @a __s. Returns an integer < 0
2195 * if this substring is ordered before the string from @a __s,
2196 * 0 if their values are equivalent, or > 0 if this substring
2197 * is ordered after the string from @a __s. Determines the
2198 * effective length rlen of the strings to compare as the
2199 * smallest of the length of the substring and @a __n2. The
2200 * function then compares the two strings by calling
2201 * traits::compare(substring.data(),__s,rlen). If the result of
2202 * the comparison is nonzero returns it, otherwise the shorter
2203 * one is ordered first.
2205 * NB: __s must have at least n2 characters, <em>\\0</em> has no special
2209 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
,
2210 size_type __n2
) const;
2215 * @brief Concatenate two strings.
2216 * @param __lhs First string.
2217 * @param __rhs Last string.
2218 * @return New string with value of @a __lhs followed by @a __rhs.
2220 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2221 template <typename
, typename
, typename
> class _Base
>
2222 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2223 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2224 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2227 * @brief Concatenate C string and string.
2228 * @param __lhs First string.
2229 * @param __rhs Last string.
2230 * @return New string with value of @a __lhs followed by @a __rhs.
2232 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2233 template <typename
, typename
, typename
> class _Base
>
2234 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2235 operator+(const _CharT
* __lhs
,
2236 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2239 * @brief Concatenate character and string.
2240 * @param __lhs First string.
2241 * @param __rhs Last string.
2242 * @return New string with @a __lhs followed by @a __rhs.
2244 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2245 template <typename
, typename
, typename
> class _Base
>
2246 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2247 operator+(_CharT __lhs
,
2248 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2251 * @brief Concatenate string and C string.
2252 * @param __lhs First string.
2253 * @param __rhs Last string.
2254 * @return New string with @a __lhs followed by @a __rhs.
2256 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2257 template <typename
, typename
, typename
> class _Base
>
2258 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2259 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2260 const _CharT
* __rhs
);
2263 * @brief Concatenate string and character.
2264 * @param __lhs First string.
2265 * @param __rhs Last string.
2266 * @return New string with @a __lhs followed by @a __rhs.
2268 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2269 template <typename
, typename
, typename
> class _Base
>
2270 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2271 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2274 #if __cplusplus >= 201103L
2275 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2276 template <typename
, typename
, typename
> class _Base
>
2277 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2278 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2279 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2280 { return std::move(__lhs
.append(__rhs
)); }
2282 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2283 template <typename
, typename
, typename
> class _Base
>
2284 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2285 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2286 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2287 { return std::move(__rhs
.insert(0, __lhs
)); }
2289 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2290 template <typename
, typename
, typename
> class _Base
>
2291 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2292 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2293 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2295 const auto __size
= __lhs
.size() + __rhs
.size();
2296 const bool __cond
= (__size
> __lhs
.capacity()
2297 && __size
<= __rhs
.capacity());
2298 return __cond
? std::move(__rhs
.insert(0, __lhs
))
2299 : std::move(__lhs
.append(__rhs
));
2302 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2303 template <typename
, typename
, typename
> class _Base
>
2304 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2305 operator+(const _CharT
* __lhs
,
2306 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2307 { return std::move(__rhs
.insert(0, __lhs
)); }
2309 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2310 template <typename
, typename
, typename
> class _Base
>
2311 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2312 operator+(_CharT __lhs
,
2313 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2314 { return std::move(__rhs
.insert(0, 1, __lhs
)); }
2316 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2317 template <typename
, typename
, typename
> class _Base
>
2318 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2319 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2320 const _CharT
* __rhs
)
2321 { return std::move(__lhs
.append(__rhs
)); }
2323 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2324 template <typename
, typename
, typename
> class _Base
>
2325 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2326 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2328 { return std::move(__lhs
.append(1, __rhs
)); }
2333 * @brief Test equivalence of two strings.
2334 * @param __lhs First string.
2335 * @param __rhs Second string.
2336 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2338 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2339 template <typename
, typename
, typename
> class _Base
>
2341 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2342 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2344 return __lhs
.size() == __rhs
.size()
2345 && !_Traits::compare(__lhs
.data(), __rhs
.data(), __lhs
.size());
2349 * @brief Test equivalence of string and C string.
2350 * @param __lhs String.
2351 * @param __rhs C string.
2352 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2354 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2355 template <typename
, typename
, typename
> class _Base
>
2357 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2358 const _CharT
* __rhs
)
2360 return __lhs
.size() == _Traits::length(__rhs
)
2361 && !_Traits::compare(__lhs
.data(), __rhs
, __lhs
.size());
2365 * @brief Test equivalence of C string and string.
2366 * @param __lhs C string.
2367 * @param __rhs String.
2368 * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise.
2370 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2371 template <typename
, typename
, typename
> class _Base
>
2373 operator==(const _CharT
* __lhs
,
2374 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2375 { return __rhs
== __lhs
; }
2379 * @brief Test difference of two strings.
2380 * @param __lhs First string.
2381 * @param __rhs Second string.
2382 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2384 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2385 template <typename
, typename
, typename
> class _Base
>
2387 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2388 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2389 { return !(__lhs
== __rhs
); }
2392 * @brief Test difference of C string and string.
2393 * @param __lhs C string.
2394 * @param __rhs String.
2395 * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise.
2397 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2398 template <typename
, typename
, typename
> class _Base
>
2400 operator!=(const _CharT
* __lhs
,
2401 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2402 { return !(__rhs
== __lhs
); }
2405 * @brief Test difference of string and C string.
2406 * @param __lhs String.
2407 * @param __rhs C string.
2408 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2410 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2411 template <typename
, typename
, typename
> class _Base
>
2413 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2414 const _CharT
* __rhs
)
2415 { return !(__lhs
== __rhs
); }
2419 * @brief Test if string precedes string.
2420 * @param __lhs First string.
2421 * @param __rhs Second string.
2422 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2424 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2425 template <typename
, typename
, typename
> class _Base
>
2427 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2428 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2429 { return __lhs
.compare(__rhs
) < 0; }
2432 * @brief Test if string precedes C string.
2433 * @param __lhs String.
2434 * @param __rhs C string.
2435 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2437 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2438 template <typename
, typename
, typename
> class _Base
>
2440 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2441 const _CharT
* __rhs
)
2442 { return __lhs
.compare(__rhs
) < 0; }
2445 * @brief Test if C string precedes string.
2446 * @param __lhs C string.
2447 * @param __rhs String.
2448 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2450 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2451 template <typename
, typename
, typename
> class _Base
>
2453 operator<(const _CharT
* __lhs
,
2454 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2455 { return __rhs
.compare(__lhs
) > 0; }
2459 * @brief Test if string follows string.
2460 * @param __lhs First string.
2461 * @param __rhs Second string.
2462 * @return True if @a __lhs follows @a __rhs. False otherwise.
2464 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2465 template <typename
, typename
, typename
> class _Base
>
2467 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2468 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2469 { return __lhs
.compare(__rhs
) > 0; }
2472 * @brief Test if string follows C string.
2473 * @param __lhs String.
2474 * @param __rhs C string.
2475 * @return True if @a __lhs follows @a __rhs. False otherwise.
2477 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2478 template <typename
, typename
, typename
> class _Base
>
2480 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2481 const _CharT
* __rhs
)
2482 { return __lhs
.compare(__rhs
) > 0; }
2485 * @brief Test if C string follows string.
2486 * @param __lhs C string.
2487 * @param __rhs String.
2488 * @return True if @a __lhs follows @a __rhs. False otherwise.
2490 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2491 template <typename
, typename
, typename
> class _Base
>
2493 operator>(const _CharT
* __lhs
,
2494 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2495 { return __rhs
.compare(__lhs
) < 0; }
2499 * @brief Test if string doesn't follow string.
2500 * @param __lhs First string.
2501 * @param __rhs Second string.
2502 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2504 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2505 template <typename
, typename
, typename
> class _Base
>
2507 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2508 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2509 { return __lhs
.compare(__rhs
) <= 0; }
2512 * @brief Test if string doesn't follow C string.
2513 * @param __lhs String.
2514 * @param __rhs C string.
2515 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2517 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2518 template <typename
, typename
, typename
> class _Base
>
2520 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2521 const _CharT
* __rhs
)
2522 { return __lhs
.compare(__rhs
) <= 0; }
2525 * @brief Test if C string doesn't follow string.
2526 * @param __lhs C string.
2527 * @param __rhs String.
2528 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2530 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2531 template <typename
, typename
, typename
> class _Base
>
2533 operator<=(const _CharT
* __lhs
,
2534 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2535 { return __rhs
.compare(__lhs
) >= 0; }
2539 * @brief Test if string doesn't precede string.
2540 * @param __lhs First string.
2541 * @param __rhs Second string.
2542 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2544 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2545 template <typename
, typename
, typename
> class _Base
>
2547 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2548 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2549 { return __lhs
.compare(__rhs
) >= 0; }
2552 * @brief Test if string doesn't precede C string.
2553 * @param __lhs String.
2554 * @param __rhs C string.
2555 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2557 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2558 template <typename
, typename
, typename
> class _Base
>
2560 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2561 const _CharT
* __rhs
)
2562 { return __lhs
.compare(__rhs
) >= 0; }
2565 * @brief Test if C string doesn't precede string.
2566 * @param __lhs C string.
2567 * @param __rhs String.
2568 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2570 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2571 template <typename
, typename
, typename
> class _Base
>
2573 operator>=(const _CharT
* __lhs
,
2574 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2575 { return __rhs
.compare(__lhs
) <= 0; }
2578 * @brief Swap contents of two strings.
2579 * @param __lhs First string.
2580 * @param __rhs Second string.
2582 * Exchanges the contents of @a __lhs and @a __rhs in constant time.
2584 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2585 template <typename
, typename
, typename
> class _Base
>
2587 swap(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2588 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2589 { __lhs
.swap(__rhs
); }
2591 _GLIBCXX_END_NAMESPACE_VERSION
2594 namespace std
_GLIBCXX_VISIBILITY(default)
2596 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2599 * @brief Read stream into a string.
2600 * @param __is Input stream.
2601 * @param __str Buffer to store into.
2602 * @return Reference to the input stream.
2604 * Stores characters from @a __is into @a __str until whitespace is
2605 * found, the end of the stream is encountered, or str.max_size()
2606 * is reached. If is.width() is non-zero, that is the limit on the
2607 * number of characters stored into @a __str. Any previous
2608 * contents of @a __str are erased.
2610 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2611 template <typename
, typename
, typename
> class _Base
>
2612 basic_istream
<_CharT
, _Traits
>&
2613 operator>>(basic_istream
<_CharT
, _Traits
>& __is
,
2614 __gnu_cxx::__versa_string
<_CharT
, _Traits
,
2615 _Alloc
, _Base
>& __str
);
2618 * @brief Write string to a stream.
2619 * @param __os Output stream.
2620 * @param __str String to write out.
2621 * @return Reference to the output stream.
2623 * Output characters of @a __str into os following the same rules as for
2624 * writing a C string.
2626 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2627 template <typename
, typename
, typename
> class _Base
>
2628 inline basic_ostream
<_CharT
, _Traits
>&
2629 operator<<(basic_ostream
<_CharT
, _Traits
>& __os
,
2630 const __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
,
2633 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2634 // 586. string inserter not a formatted function
2635 return __ostream_insert(__os
, __str
.data(), __str
.size());
2639 * @brief Read a line from stream into a string.
2640 * @param __is Input stream.
2641 * @param __str Buffer to store into.
2642 * @param __delim Character marking end of line.
2643 * @return Reference to the input stream.
2645 * Stores characters from @a __is into @a __str until @a __delim is
2646 * found, the end of the stream is encountered, or str.max_size()
2647 * is reached. If is.width() is non-zero, that is the limit on the
2648 * number of characters stored into @a __str. Any previous
2649 * contents of @a __str are erased. If @a delim was encountered,
2650 * it is extracted but not stored into @a __str.
2652 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2653 template <typename
, typename
, typename
> class _Base
>
2654 basic_istream
<_CharT
, _Traits
>&
2655 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2656 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
,
2660 * @brief Read a line from stream into a string.
2661 * @param __is Input stream.
2662 * @param __str Buffer to store into.
2663 * @return Reference to the input stream.
2665 * Stores characters from is into @a __str until '\n' is
2666 * found, the end of the stream is encountered, or str.max_size()
2667 * is reached. If is.width() is non-zero, that is the limit on the
2668 * number of characters stored into @a __str. Any previous
2669 * contents of @a __str are erased. If end of line was
2670 * encountered, it is extracted but not stored into @a __str.
2672 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2673 template <typename
, typename
, typename
> class _Base
>
2674 inline basic_istream
<_CharT
, _Traits
>&
2675 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2676 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
)
2677 { return getline(__is
, __str
, __is
.widen('\n')); }
2679 _GLIBCXX_END_NAMESPACE_VERSION
2682 #if __cplusplus >= 201103L
2684 #include <ext/string_conversions.h>
2686 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
2688 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2690 #if _GLIBCXX_USE_C99_STDLIB
2691 // 21.4 Numeric Conversions [string.conversions].
2693 stoi(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2694 { return __gnu_cxx::__stoa
<long, int>(&std::strtol
, "stoi", __str
.c_str(),
2698 stol(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2699 { return __gnu_cxx::__stoa(&std::strtol
, "stol", __str
.c_str(),
2702 inline unsigned long
2703 stoul(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2704 { return __gnu_cxx::__stoa(&std::strtoul
, "stoul", __str
.c_str(),
2708 stoll(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2709 { return __gnu_cxx::__stoa(&std::strtoll
, "stoll", __str
.c_str(),
2712 inline unsigned long long
2713 stoull(const __vstring
& __str
, std::size_t* __idx
, int __base
= 10)
2714 { return __gnu_cxx::__stoa(&std::strtoull
, "stoull", __str
.c_str(),
2717 // NB: strtof vs strtod.
2719 stof(const __vstring
& __str
, std::size_t* __idx
= 0)
2720 { return __gnu_cxx::__stoa(&std::strtof
, "stof", __str
.c_str(), __idx
); }
2723 stod(const __vstring
& __str
, std::size_t* __idx
= 0)
2724 { return __gnu_cxx::__stoa(&std::strtod
, "stod", __str
.c_str(), __idx
); }
2727 stold(const __vstring
& __str
, std::size_t* __idx
= 0)
2728 { return __gnu_cxx::__stoa(&std::strtold
, "stold", __str
.c_str(), __idx
); }
2729 #endif // _GLIBCXX_USE_C99_STDLIB
2731 #if _GLIBCXX_USE_C99_STDIO
2732 // NB: (v)snprintf vs sprintf.
2736 to_string(int __val
)
2737 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, 4 * sizeof(int),
2741 to_string(unsigned __val
)
2742 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2743 4 * sizeof(unsigned),
2747 to_string(long __val
)
2748 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2753 to_string(unsigned long __val
)
2754 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2755 4 * sizeof(unsigned long),
2760 to_string(long long __val
)
2761 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2762 4 * sizeof(long long),
2766 to_string(unsigned long long __val
)
2767 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2768 4 * sizeof(unsigned long long),
2772 to_string(float __val
)
2774 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2775 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2780 to_string(double __val
)
2782 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2783 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2788 to_string(long double __val
)
2790 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2791 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2794 #endif // _GLIBCXX_USE_C99_STDIO
2796 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
2798 stoi(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2799 { return __gnu_cxx::__stoa
<long, int>(&std::wcstol
, "stoi", __str
.c_str(),
2803 stol(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2804 { return __gnu_cxx::__stoa(&std::wcstol
, "stol", __str
.c_str(),
2807 inline unsigned long
2808 stoul(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2809 { return __gnu_cxx::__stoa(&std::wcstoul
, "stoul", __str
.c_str(),
2813 stoll(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2814 { return __gnu_cxx::__stoa(&std::wcstoll
, "stoll", __str
.c_str(),
2817 inline unsigned long long
2818 stoull(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2819 { return __gnu_cxx::__stoa(&std::wcstoull
, "stoull", __str
.c_str(),
2822 // NB: wcstof vs wcstod.
2824 stof(const __wvstring
& __str
, std::size_t* __idx
= 0)
2825 { return __gnu_cxx::__stoa(&std::wcstof
, "stof", __str
.c_str(), __idx
); }
2828 stod(const __wvstring
& __str
, std::size_t* __idx
= 0)
2829 { return __gnu_cxx::__stoa(&std::wcstod
, "stod", __str
.c_str(), __idx
); }
2832 stold(const __wvstring
& __str
, std::size_t* __idx
= 0)
2833 { return __gnu_cxx::__stoa(&std::wcstold
, "stold", __str
.c_str(), __idx
); }
2835 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2838 to_wstring(int __val
)
2839 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2844 to_wstring(unsigned __val
)
2845 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2846 4 * sizeof(unsigned),
2850 to_wstring(long __val
)
2851 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2856 to_wstring(unsigned long __val
)
2857 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2858 4 * sizeof(unsigned long),
2862 to_wstring(long long __val
)
2863 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2864 4 * sizeof(long long),
2868 to_wstring(unsigned long long __val
)
2869 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2870 4 * sizeof(unsigned long long),
2874 to_wstring(float __val
)
2876 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2877 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2882 to_wstring(double __val
)
2884 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2885 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2890 to_wstring(long double __val
)
2892 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2893 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2896 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2897 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
2899 _GLIBCXX_END_NAMESPACE_VERSION
2904 #if __cplusplus >= 201103L
2906 #include <bits/functional_hash.h>
2908 namespace std
_GLIBCXX_VISIBILITY(default)
2910 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2912 /// std::hash specialization for __vstring.
2914 struct hash
<__gnu_cxx::__vstring
>
2915 : public __hash_base
<size_t, __gnu_cxx::__vstring
>
2918 operator()(const __gnu_cxx::__vstring
& __s
) const noexcept
2919 { return std::_Hash_impl::hash(__s
.data(), __s
.length()); }
2922 /// std::hash specialization for __wvstring.
2924 struct hash
<__gnu_cxx::__wvstring
>
2925 : public __hash_base
<size_t, __gnu_cxx::__wvstring
>
2928 operator()(const __gnu_cxx::__wvstring
& __s
) const noexcept
2929 { return std::_Hash_impl::hash(__s
.data(),
2930 __s
.length() * sizeof(wchar_t)); }
2933 /// std::hash specialization for __u16vstring.
2935 struct hash
<__gnu_cxx::__u16vstring
>
2936 : public __hash_base
<size_t, __gnu_cxx::__u16vstring
>
2939 operator()(const __gnu_cxx::__u16vstring
& __s
) const noexcept
2940 { return std::_Hash_impl::hash(__s
.data(),
2941 __s
.length() * sizeof(char16_t
)); }
2944 /// std::hash specialization for __u32vstring.
2946 struct hash
<__gnu_cxx::__u32vstring
>
2947 : public __hash_base
<size_t, __gnu_cxx::__u32vstring
>
2950 operator()(const __gnu_cxx::__u32vstring
& __s
) const noexcept
2951 { return std::_Hash_impl::hash(__s
.data(),
2952 __s
.length() * sizeof(char32_t
)); }
2955 _GLIBCXX_END_NAMESPACE_VERSION
2960 #include <ext/vstring.tcc>
2962 #endif /* _VSTRING_H */