1 // Versatile string -*- C++ -*-
3 // Copyright (C) 2005-2017 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 #if __cplusplus >= 201103L
35 #include <initializer_list>
38 #include <ext/vstring_util.h>
39 #include <ext/rc_string_base.h>
40 #include <ext/sso_string_base.h>
42 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
44 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 * @class __versa_string vstring.h
48 * @brief Template class __versa_string.
51 * Data structure managing sequences of characters and
52 * character-like objects.
54 template<typename _CharT
, typename _Traits
, typename _Alloc
,
55 template <typename
, typename
, typename
> class _Base
>
57 : private _Base
<_CharT
, _Traits
, _Alloc
>
59 typedef _Base
<_CharT
, _Traits
, _Alloc
> __vstring_base
;
60 typedef typename
__vstring_base::_CharT_alloc_type _CharT_alloc_type
;
64 typedef _Traits traits_type
;
65 typedef typename
_Traits::char_type value_type
;
66 typedef _Alloc allocator_type
;
67 typedef typename
_CharT_alloc_type::size_type size_type
;
68 typedef typename
_CharT_alloc_type::difference_type difference_type
;
69 typedef value_type
& reference
;
70 typedef const value_type
& const_reference
;
71 typedef typename
_CharT_alloc_type::pointer pointer
;
72 typedef typename
_CharT_alloc_type::const_pointer const_pointer
;
73 typedef __gnu_cxx::__normal_iterator
<pointer
, __versa_string
> iterator
;
74 typedef __gnu_cxx::__normal_iterator
<const_pointer
, __versa_string
>
76 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
77 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
79 // Data Member (public):
80 /// Value returned by various member functions when they fail.
81 static const size_type npos
= static_cast<size_type
>(-1);
85 _M_check(size_type __pos
, const char* __s
) const
87 if (__pos
> this->size())
88 std::__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
89 "this->size() (which is %zu)"),
90 __s
, __pos
, this->size());
95 _M_check_length(size_type __n1
, size_type __n2
, const char* __s
) const
97 if (this->max_size() - (this->size() - __n1
) < __n2
)
98 std::__throw_length_error(__N(__s
));
101 // NB: _M_limit doesn't check for a bad __pos value.
103 _M_limit(size_type __pos
, size_type __off
) const _GLIBCXX_NOEXCEPT
105 const bool __testoff
= __off
< this->size() - __pos
;
106 return __testoff
? __off
: this->size() - __pos
;
109 // True if _Rep and source do not overlap.
111 _M_disjunct(const _CharT
* __s
) const _GLIBCXX_NOEXCEPT
113 return (std::less
<const _CharT
*>()(__s
, this->_M_data())
114 || std::less
<const _CharT
*>()(this->_M_data()
115 + this->size(), __s
));
118 // For the internal use we have functions similar to `begin'/`end'
119 // but they do not call _M_leak.
121 _M_ibegin() const _GLIBCXX_NOEXCEPT
122 { return iterator(this->_M_data()); }
125 _M_iend() const _GLIBCXX_NOEXCEPT
126 { return iterator(this->_M_data() + this->_M_length()); }
129 // Construct/copy/destroy:
130 // NB: We overload ctors in some cases instead of using default
131 // arguments, per 17.4.4.4 para. 2 item 2.
134 * @brief Construct an empty string using allocator @a a.
137 __versa_string(const _Alloc
& __a
= _Alloc()) _GLIBCXX_NOEXCEPT
138 : __vstring_base(__a
) { }
140 // NB: per LWG issue 42, semantics different from IS:
142 * @brief Construct string with copy of value of @a __str.
143 * @param __str Source string.
145 __versa_string(const __versa_string
& __str
)
146 : __vstring_base(__str
) { }
148 #if __cplusplus >= 201103L
150 * @brief String move constructor.
151 * @param __str Source string.
153 * The newly-constructed %string contains the exact contents of
154 * @a __str. The contents of @a __str are a valid, but unspecified
157 __versa_string(__versa_string
&& __str
) noexcept
158 : __vstring_base(std::move(__str
)) { }
161 * @brief Construct string from an initializer list.
162 * @param __l std::initializer_list of characters.
163 * @param __a Allocator to use (default is default allocator).
165 __versa_string(std::initializer_list
<_CharT
> __l
,
166 const _Alloc
& __a
= _Alloc())
167 : __vstring_base(__l
.begin(), __l
.end(), __a
) { }
171 * @brief Construct string as copy of a substring.
172 * @param __str Source string.
173 * @param __pos Index of first character to copy from.
174 * @param __n Number of characters to copy (default remainder).
176 __versa_string(const __versa_string
& __str
, size_type __pos
,
177 size_type __n
= npos
)
178 : __vstring_base(__str
._M_data()
179 + __str
._M_check(__pos
,
180 "__versa_string::__versa_string"),
181 __str
._M_data() + __str
._M_limit(__pos
, __n
)
182 + __pos
, _Alloc()) { }
185 * @brief Construct string as copy of a substring.
186 * @param __str Source string.
187 * @param __pos Index of first character to copy from.
188 * @param __n Number of characters to copy.
189 * @param __a Allocator to use.
191 __versa_string(const __versa_string
& __str
, size_type __pos
,
192 size_type __n
, const _Alloc
& __a
)
193 : __vstring_base(__str
._M_data()
194 + __str
._M_check(__pos
,
195 "__versa_string::__versa_string"),
196 __str
._M_data() + __str
._M_limit(__pos
, __n
)
200 * @brief Construct string initialized by a character array.
201 * @param __s Source character array.
202 * @param __n Number of characters to copy.
203 * @param __a Allocator to use (default is default allocator).
205 * NB: @a __s must have at least @a __n characters, '\\0' has no special
208 __versa_string(const _CharT
* __s
, size_type __n
,
209 const _Alloc
& __a
= _Alloc())
210 : __vstring_base(__s
, __s
+ __n
, __a
) { }
213 * @brief Construct string as copy of a C string.
214 * @param __s Source C string.
215 * @param __a Allocator to use (default is default allocator).
217 __versa_string(const _CharT
* __s
, const _Alloc
& __a
= _Alloc())
218 : __vstring_base(__s
, __s
? __s
+ traits_type::length(__s
) :
222 * @brief Construct string as multiple characters.
223 * @param __n Number of characters.
224 * @param __c Character to use.
225 * @param __a Allocator to use (default is default allocator).
227 __versa_string(size_type __n
, _CharT __c
, const _Alloc
& __a
= _Alloc())
228 : __vstring_base(__n
, __c
, __a
) { }
231 * @brief Construct string as copy of a range.
232 * @param __beg Start of range.
233 * @param __end End of range.
234 * @param __a Allocator to use (default is default allocator).
236 #if __cplusplus >= 201103L
237 template<class _InputIterator
,
238 typename
= std::_RequireInputIter
<_InputIterator
>>
240 template<class _InputIterator
>
242 __versa_string(_InputIterator __beg
, _InputIterator __end
,
243 const _Alloc
& __a
= _Alloc())
244 : __vstring_base(__beg
, __end
, __a
) { }
247 * @brief Destroy the string instance.
249 ~__versa_string() _GLIBCXX_NOEXCEPT
{ }
252 * @brief Assign the value of @a str to this string.
253 * @param __str Source string.
256 operator=(const __versa_string
& __str
)
257 { return this->assign(__str
); }
259 #if __cplusplus >= 201103L
261 * @brief String move assignment operator.
262 * @param __str Source string.
264 * The contents of @a __str are moved into this string (without
265 * copying). @a __str is a valid, but unspecified string.
268 operator=(__versa_string
&& __str
) noexcept
276 * @brief Set value to string constructed from initializer list.
277 * @param __l std::initializer_list.
280 operator=(std::initializer_list
<_CharT
> __l
)
282 this->assign(__l
.begin(), __l
.end());
288 * @brief Copy contents of @a __s into this string.
289 * @param __s Source null-terminated string.
292 operator=(const _CharT
* __s
)
293 { return this->assign(__s
); }
296 * @brief Set value to string of length 1.
297 * @param __c Source character.
299 * Assigning to a character makes this string length 1 and
300 * (*this)[0] == @a __c.
303 operator=(_CharT __c
)
305 this->assign(1, __c
);
311 * Returns a read/write iterator that points to the first character in
312 * the %string. Unshares the string.
315 begin() _GLIBCXX_NOEXCEPT
318 return iterator(this->_M_data());
322 * Returns a read-only (constant) iterator that points to the first
323 * character in the %string.
326 begin() const _GLIBCXX_NOEXCEPT
327 { return const_iterator(this->_M_data()); }
330 * Returns a read/write iterator that points one past the last
331 * character in the %string. Unshares the string.
334 end() _GLIBCXX_NOEXCEPT
337 return iterator(this->_M_data() + this->size());
341 * Returns a read-only (constant) iterator that points one past the
342 * last character in the %string.
345 end() const _GLIBCXX_NOEXCEPT
346 { return const_iterator(this->_M_data() + this->size()); }
349 * Returns a read/write reverse iterator that points to the last
350 * character in the %string. Iteration is done in reverse element
351 * order. Unshares the string.
354 rbegin() _GLIBCXX_NOEXCEPT
355 { return reverse_iterator(this->end()); }
358 * Returns a read-only (constant) reverse iterator that points
359 * to the last character in the %string. Iteration is done in
360 * reverse element order.
362 const_reverse_iterator
363 rbegin() const _GLIBCXX_NOEXCEPT
364 { return const_reverse_iterator(this->end()); }
367 * Returns a read/write reverse iterator that points to one before the
368 * first character in the %string. Iteration is done in reverse
369 * element order. Unshares the string.
372 rend() _GLIBCXX_NOEXCEPT
373 { return reverse_iterator(this->begin()); }
376 * Returns a read-only (constant) reverse iterator that points
377 * to one before the first character in the %string. Iteration
378 * is done in reverse element order.
380 const_reverse_iterator
381 rend() const _GLIBCXX_NOEXCEPT
382 { return const_reverse_iterator(this->begin()); }
384 #if __cplusplus >= 201103L
386 * Returns a read-only (constant) iterator that points to the first
387 * character in the %string.
390 cbegin() const noexcept
391 { return const_iterator(this->_M_data()); }
394 * Returns a read-only (constant) iterator that points one past the
395 * last character in the %string.
398 cend() const noexcept
399 { return const_iterator(this->_M_data() + this->size()); }
402 * Returns a read-only (constant) reverse iterator that points
403 * to the last character in the %string. Iteration is done in
404 * reverse element order.
406 const_reverse_iterator
407 crbegin() const noexcept
408 { return const_reverse_iterator(this->end()); }
411 * Returns a read-only (constant) reverse iterator that points
412 * to one before the first character in the %string. Iteration
413 * is done in reverse element order.
415 const_reverse_iterator
416 crend() const noexcept
417 { return const_reverse_iterator(this->begin()); }
422 /// Returns the number of characters in the string, not including any
423 /// null-termination.
425 size() const _GLIBCXX_NOEXCEPT
426 { return this->_M_length(); }
428 /// Returns the number of characters in the string, not including any
429 /// null-termination.
431 length() const _GLIBCXX_NOEXCEPT
432 { return this->_M_length(); }
434 /// Returns the size() of the largest possible %string.
436 max_size() const _GLIBCXX_NOEXCEPT
437 { return this->_M_max_size(); }
440 * @brief Resizes the %string to the specified number of characters.
441 * @param __n Number of characters the %string should contain.
442 * @param __c Character to fill any new elements.
444 * This function will %resize the %string to the specified
445 * number of characters. If the number is smaller than the
446 * %string's current size the %string is truncated, otherwise
447 * the %string is extended and new elements are set to @a __c.
450 resize(size_type __n
, _CharT __c
);
453 * @brief Resizes the %string to the specified number of characters.
454 * @param __n Number of characters the %string should contain.
456 * This function will resize the %string to the specified
457 * length. If the new size is smaller than the %string's
458 * current size the %string is truncated, otherwise the %string
459 * is extended and new characters are default-constructed. For
460 * basic types such as char, this means setting them to 0.
463 resize(size_type __n
)
464 { this->resize(__n
, _CharT()); }
466 #if __cplusplus >= 201103L
467 /// A non-binding request to reduce capacity() to size().
469 shrink_to_fit() noexcept
471 if (capacity() > size())
474 { this->reserve(0); }
482 * Returns the total number of characters that the %string can
483 * hold before needing to allocate more memory.
486 capacity() const _GLIBCXX_NOEXCEPT
487 { return this->_M_capacity(); }
490 * @brief Attempt to preallocate enough memory for specified number of
492 * @param __res_arg Number of characters required.
493 * @throw std::length_error If @a __res_arg exceeds @c max_size().
495 * This function attempts to reserve enough memory for the
496 * %string to hold the specified number of characters. If the
497 * number requested is more than max_size(), length_error is
500 * The advantage of this function is that if optimal code is a
501 * necessity and the user can determine the string length that
502 * will be required, the user can reserve the memory in
503 * %advance, and thus prevent a possible reallocation of memory
504 * and copying of %string data.
507 reserve(size_type __res_arg
= 0)
508 { this->_M_reserve(__res_arg
); }
511 * Erases the string, making it empty.
514 clear() _GLIBCXX_NOEXCEPT
515 { this->_M_clear(); }
518 * Returns true if the %string is empty. Equivalent to
519 * <code>*this == ""</code>.
522 empty() const _GLIBCXX_NOEXCEPT
523 { return this->size() == 0; }
527 * @brief Subscript access to the data contained in the %string.
528 * @param __pos The index of the character to access.
529 * @return Read-only (constant) reference to the character.
531 * This operator allows for easy, array-style, data access.
532 * Note that data access with this operator is unchecked and
533 * out_of_range lookups are not defined. (For checked lookups
537 operator[] (size_type __pos
) const _GLIBCXX_NOEXCEPT
539 __glibcxx_assert(__pos
<= this->size());
540 return this->_M_data()[__pos
];
544 * @brief Subscript access to the data contained in the %string.
545 * @param __pos The index of the character to access.
546 * @return Read/write reference to the character.
548 * This operator allows for easy, array-style, data access.
549 * Note that data access with this operator is unchecked and
550 * out_of_range lookups are not defined. (For checked lookups
551 * see at().) Unshares the string.
554 operator[](size_type __pos
) _GLIBCXX_NOEXCEPT
556 // Allow pos == size() both in C++98 mode, as v3 extension,
557 // and in C++11 mode.
558 __glibcxx_assert(__pos
<= this->size());
559 // In pedantic mode be strict in C++98 mode.
560 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus
>= 201103L
561 || __pos
< this->size());
563 return this->_M_data()[__pos
];
567 * @brief Provides access to the data contained in the %string.
568 * @param __n The index of the character to access.
569 * @return Read-only (const) reference to the character.
570 * @throw std::out_of_range If @a __n is an invalid index.
572 * This function provides for safer data access. The parameter
573 * is first checked that it is in the range of the string. The
574 * function throws out_of_range if the check fails.
577 at(size_type __n
) const
579 if (__n
>= this->size())
580 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
581 "(which is %zu) >= this->size() "
584 return this->_M_data()[__n
];
588 * @brief Provides access to the data contained in the %string.
589 * @param __n The index of the character to access.
590 * @return Read/write reference to the character.
591 * @throw std::out_of_range If @a __n is an invalid index.
593 * This function provides for safer data access. The parameter
594 * is first checked that it is in the range of the string. The
595 * function throws out_of_range if the check fails. Success
596 * results in unsharing the string.
601 if (__n
>= this->size())
602 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
603 "(which is %zu) >= this->size() "
607 return this->_M_data()[__n
];
610 #if __cplusplus >= 201103L
612 * Returns a read/write reference to the data at the first
613 * element of the %string.
617 { return operator[](0); }
620 * Returns a read-only (constant) reference to the data at the first
621 * element of the %string.
624 front() const noexcept
625 { return operator[](0); }
628 * Returns a read/write reference to the data at the last
629 * element of the %string.
633 { return operator[](this->size() - 1); }
636 * Returns a read-only (constant) reference to the data at the
637 * last element of the %string.
640 back() const noexcept
641 { return operator[](this->size() - 1); }
646 * @brief Append a string to this string.
647 * @param __str The string to append.
648 * @return Reference to this string.
651 operator+=(const __versa_string
& __str
)
652 { return this->append(__str
); }
655 * @brief Append a C string.
656 * @param __s The C string to append.
657 * @return Reference to this string.
660 operator+=(const _CharT
* __s
)
661 { return this->append(__s
); }
664 * @brief Append a character.
665 * @param __c The character to append.
666 * @return Reference to this string.
669 operator+=(_CharT __c
)
671 this->push_back(__c
);
675 #if __cplusplus >= 201103L
677 * @brief Append an initializer_list of characters.
678 * @param __l The initializer_list of characters to be appended.
679 * @return Reference to this string.
682 operator+=(std::initializer_list
<_CharT
> __l
)
683 { return this->append(__l
.begin(), __l
.end()); }
687 * @brief Append a string to this string.
688 * @param __str The string to append.
689 * @return Reference to this string.
692 append(const __versa_string
& __str
)
693 { return _M_append(__str
._M_data(), __str
.size()); }
696 * @brief Append a substring.
697 * @param __str The string to append.
698 * @param __pos Index of the first character of str to append.
699 * @param __n The number of characters to append.
700 * @return Reference to this string.
701 * @throw std::out_of_range if @a pos is not a valid index.
703 * This function appends @a __n characters from @a __str
704 * starting at @a __pos to this string. If @a __n is is larger
705 * than the number of available characters in @a __str, the
706 * remainder of @a __str is appended.
709 append(const __versa_string
& __str
, size_type __pos
, size_type __n
)
710 { return _M_append(__str
._M_data()
711 + __str
._M_check(__pos
, "__versa_string::append"),
712 __str
._M_limit(__pos
, __n
)); }
715 * @brief Append a C substring.
716 * @param __s The C string to append.
717 * @param __n The number of characters to append.
718 * @return Reference to this string.
721 append(const _CharT
* __s
, size_type __n
)
723 __glibcxx_requires_string_len(__s
, __n
);
724 _M_check_length(size_type(0), __n
, "__versa_string::append");
725 return _M_append(__s
, __n
);
729 * @brief Append a C string.
730 * @param __s The C string to append.
731 * @return Reference to this string.
734 append(const _CharT
* __s
)
736 __glibcxx_requires_string(__s
);
737 const size_type __n
= traits_type::length(__s
);
738 _M_check_length(size_type(0), __n
, "__versa_string::append");
739 return _M_append(__s
, __n
);
743 * @brief Append multiple characters.
744 * @param __n The number of characters to append.
745 * @param __c The character to use.
746 * @return Reference to this string.
748 * Appends n copies of c to this string.
751 append(size_type __n
, _CharT __c
)
752 { return _M_replace_aux(this->size(), size_type(0), __n
, __c
); }
754 #if __cplusplus >= 201103L
756 * @brief Append an initializer_list of characters.
757 * @param __l The initializer_list of characters to append.
758 * @return Reference to this string.
761 append(std::initializer_list
<_CharT
> __l
)
762 { return this->append(__l
.begin(), __l
.end()); }
766 * @brief Append a range of characters.
767 * @param __first Iterator referencing the first character to append.
768 * @param __last Iterator marking the end of the range.
769 * @return Reference to this string.
771 * Appends characters in the range [first,last) to this string.
773 #if __cplusplus >= 201103L
774 template<class _InputIterator
,
775 typename
= std::_RequireInputIter
<_InputIterator
>>
777 template<class _InputIterator
>
780 append(_InputIterator __first
, _InputIterator __last
)
781 { return this->replace(_M_iend(), _M_iend(), __first
, __last
); }
784 * @brief Append a single character.
785 * @param __c Character to append.
788 push_back(_CharT __c
)
790 const size_type __size
= this->size();
791 if (__size
+ 1 > this->capacity() || this->_M_is_shared())
792 this->_M_mutate(__size
, size_type(0), 0, size_type(1));
793 traits_type::assign(this->_M_data()[__size
], __c
);
794 this->_M_set_length(__size
+ 1);
798 * @brief Set value to contents of another string.
799 * @param __str Source string to use.
800 * @return Reference to this string.
803 assign(const __versa_string
& __str
)
805 this->_M_assign(__str
);
809 #if __cplusplus >= 201103L
811 * @brief Set value to contents of another string.
812 * @param __str Source string to use.
813 * @return Reference to this string.
815 * This function sets this string to the exact contents of @a __str.
816 * @a __str is a valid, but unspecified string.
819 assign(__versa_string
&& __str
) noexcept
827 * @brief Set value to a substring of a string.
828 * @param __str The string to use.
829 * @param __pos Index of the first character of str.
830 * @param __n Number of characters to use.
831 * @return Reference to this string.
832 * @throw std::out_of_range if @a __pos is not a valid index.
834 * This function sets this string to the substring of @a __str
835 * consisting of @a __n characters at @a __pos. If @a __n is
836 * is larger than the number of available characters in @a
837 * __str, the remainder of @a __str is used.
840 assign(const __versa_string
& __str
, size_type __pos
, size_type __n
)
841 { return _M_replace(size_type(0), this->size(), __str
._M_data()
842 + __str
._M_check(__pos
, "__versa_string::assign"),
843 __str
._M_limit(__pos
, __n
)); }
846 * @brief Set value to a C substring.
847 * @param __s The C string to use.
848 * @param __n Number of characters to use.
849 * @return Reference to this string.
851 * This function sets the value of this string to the first @a
852 * __n characters of @a __s. If @a __n is is larger than the
853 * number of available characters in @a __s, the remainder of
857 assign(const _CharT
* __s
, size_type __n
)
859 __glibcxx_requires_string_len(__s
, __n
);
860 return _M_replace(size_type(0), this->size(), __s
, __n
);
864 * @brief Set value to contents of a C string.
865 * @param __s The C string to use.
866 * @return Reference to this string.
868 * This function sets the value of this string to the value of
869 * @a __s. The data is copied, so there is no dependence on @a
870 * __s once the function returns.
873 assign(const _CharT
* __s
)
875 __glibcxx_requires_string(__s
);
876 return _M_replace(size_type(0), this->size(), __s
,
877 traits_type::length(__s
));
881 * @brief Set value to multiple characters.
882 * @param __n Length of the resulting string.
883 * @param __c The character to use.
884 * @return Reference to this string.
886 * This function sets the value of this string to @a __n copies of
890 assign(size_type __n
, _CharT __c
)
891 { return _M_replace_aux(size_type(0), this->size(), __n
, __c
); }
894 * @brief Set value to a range of characters.
895 * @param __first Iterator referencing the first character to append.
896 * @param __last Iterator marking the end of the range.
897 * @return Reference to this string.
899 * Sets value of string to characters in the range
902 #if __cplusplus >= 201103L
903 template<class _InputIterator
,
904 typename
= std::_RequireInputIter
<_InputIterator
>>
906 template<class _InputIterator
>
909 assign(_InputIterator __first
, _InputIterator __last
)
910 { return this->replace(_M_ibegin(), _M_iend(), __first
, __last
); }
912 #if __cplusplus >= 201103L
914 * @brief Set value to an initializer_list of characters.
915 * @param __l The initializer_list of characters to assign.
916 * @return Reference to this string.
919 assign(std::initializer_list
<_CharT
> __l
)
920 { return this->assign(__l
.begin(), __l
.end()); }
923 #if __cplusplus >= 201103L
925 * @brief Insert multiple characters.
926 * @param __p Const_iterator referencing location in string to
928 * @param __n Number of characters to insert
929 * @param __c The character to insert.
930 * @return Iterator referencing the first inserted char.
931 * @throw std::length_error If new length exceeds @c max_size().
933 * Inserts @a __n copies of character @a __c starting at the
934 * position referenced by iterator @a __p. If adding
935 * characters causes the length to exceed max_size(),
936 * length_error is thrown. The value of the string doesn't
937 * change if an error is thrown.
940 insert(const_iterator __p
, size_type __n
, _CharT __c
)
942 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
943 const size_type __pos
= __p
- _M_ibegin();
944 this->replace(__p
, __p
, __n
, __c
);
945 return iterator(this->_M_data() + __pos
);
949 * @brief Insert multiple characters.
950 * @param __p Iterator referencing location in string to insert at.
951 * @param __n Number of characters to insert
952 * @param __c The character to insert.
953 * @throw std::length_error If new length exceeds @c max_size().
955 * Inserts @a __n copies of character @a __c starting at the
956 * position referenced by iterator @a __p. If adding
957 * characters causes the length to exceed max_size(),
958 * length_error is thrown. The value of the string doesn't
959 * change if an error is thrown.
962 insert(iterator __p
, size_type __n
, _CharT __c
)
963 { this->replace(__p
, __p
, __n
, __c
); }
966 #if __cplusplus >= 201103L
968 * @brief Insert a range of characters.
969 * @param __p Const_iterator referencing location in string to
971 * @param __beg Start of range.
972 * @param __end End of range.
973 * @return Iterator referencing the first inserted char.
974 * @throw std::length_error If new length exceeds @c max_size().
976 * Inserts characters in range [beg,end). If adding characters
977 * causes the length to exceed max_size(), length_error is
978 * thrown. The value of the string doesn't change if an error
981 template<class _InputIterator
,
982 typename
= std::_RequireInputIter
<_InputIterator
>>
984 insert(const_iterator __p
, _InputIterator __beg
, _InputIterator __end
)
986 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
987 const size_type __pos
= __p
- _M_ibegin();
988 this->replace(__p
, __p
, __beg
, __end
);
989 return iterator(this->_M_data() + __pos
);
993 * @brief Insert a range of characters.
994 * @param __p Iterator referencing location in string to insert at.
995 * @param __beg Start of range.
996 * @param __end End of range.
997 * @throw std::length_error If new length exceeds @c max_size().
999 * Inserts characters in range [beg,end). If adding characters
1000 * causes the length to exceed max_size(), length_error is
1001 * thrown. The value of the string doesn't change if an error
1004 template<class _InputIterator
>
1006 insert(iterator __p
, _InputIterator __beg
, _InputIterator __end
)
1007 { this->replace(__p
, __p
, __beg
, __end
); }
1010 #if __cplusplus >= 201103L
1012 * @brief Insert an initializer_list of characters.
1013 * @param __p Const_iterator referencing location in string to
1015 * @param __l The initializer_list of characters to insert.
1016 * @return Iterator referencing the first inserted char.
1017 * @throw std::length_error If new length exceeds @c max_size().
1020 insert(const_iterator __p
, std::initializer_list
<_CharT
> __l
)
1021 { return this->insert(__p
, __l
.begin(), __l
.end()); }
1025 * @brief Insert value of a string.
1026 * @param __pos1 Iterator referencing location in string to insert at.
1027 * @param __str The string to insert.
1028 * @return Reference to this string.
1029 * @throw std::length_error If new length exceeds @c max_size().
1031 * Inserts value of @a __str starting at @a __pos1. If adding
1032 * characters causes the length to exceed max_size(),
1033 * length_error is thrown. The value of the string doesn't
1034 * change if an error is thrown.
1037 insert(size_type __pos1
, const __versa_string
& __str
)
1038 { return this->replace(__pos1
, size_type(0),
1039 __str
._M_data(), __str
.size()); }
1042 * @brief Insert a substring.
1043 * @param __pos1 Iterator referencing location in string to insert at.
1044 * @param __str The string to insert.
1045 * @param __pos2 Start of characters in str to insert.
1046 * @param __n Number of characters to insert.
1047 * @return Reference to this string.
1048 * @throw std::length_error If new length exceeds @c max_size().
1049 * @throw std::out_of_range If @a __pos1 > size() or
1050 * @a __pos2 > @a __str.size().
1052 * Starting at @a __pos1, insert @a __n character of @a __str
1053 * beginning with @a __pos2. If adding characters causes the
1054 * length to exceed max_size(), length_error is thrown. If @a
1055 * __pos1 is beyond the end of this string or @a __pos2 is
1056 * beyond the end of @a __str, out_of_range is thrown. The
1057 * value of the string doesn't change if an error is thrown.
1060 insert(size_type __pos1
, const __versa_string
& __str
,
1061 size_type __pos2
, size_type __n
)
1062 { return this->replace(__pos1
, size_type(0), __str
._M_data()
1063 + __str
._M_check(__pos2
, "__versa_string::insert"),
1064 __str
._M_limit(__pos2
, __n
)); }
1067 * @brief Insert a C substring.
1068 * @param __pos Iterator referencing location in string to insert at.
1069 * @param __s The C string to insert.
1070 * @param __n The number of characters to insert.
1071 * @return Reference to this string.
1072 * @throw std::length_error If new length exceeds @c max_size().
1073 * @throw std::out_of_range If @a __pos is beyond the end of this
1076 * Inserts the first @a __n characters of @a __s starting at @a
1077 * __pos. If adding characters causes the length to exceed
1078 * max_size(), length_error is thrown. If @a __pos is beyond
1079 * end(), out_of_range is thrown. The value of the string
1080 * doesn't change if an error is thrown.
1083 insert(size_type __pos
, const _CharT
* __s
, size_type __n
)
1084 { return this->replace(__pos
, size_type(0), __s
, __n
); }
1087 * @brief Insert a C string.
1088 * @param __pos Iterator referencing location in string to insert at.
1089 * @param __s The C string to insert.
1090 * @return Reference to this string.
1091 * @throw std::length_error If new length exceeds @c max_size().
1092 * @throw std::out_of_range If @a __pos is beyond the end of this
1095 * Inserts the first @a __n characters of @a __s starting at @a
1096 * __pos. If adding characters causes the length to exceed
1097 * max_size(), length_error is thrown. If @a __pos is beyond
1098 * end(), out_of_range is thrown. The value of the string
1099 * doesn't change if an error is thrown.
1102 insert(size_type __pos
, const _CharT
* __s
)
1104 __glibcxx_requires_string(__s
);
1105 return this->replace(__pos
, size_type(0), __s
,
1106 traits_type::length(__s
));
1110 * @brief Insert multiple characters.
1111 * @param __pos Index in string to insert at.
1112 * @param __n Number of characters to insert
1113 * @param __c The character to insert.
1114 * @return Reference to this string.
1115 * @throw std::length_error If new length exceeds @c max_size().
1116 * @throw std::out_of_range If @a __pos is beyond the end of this
1119 * Inserts @a __n copies of character @a __c starting at index
1120 * @a __pos. If adding characters causes the length to exceed
1121 * max_size(), length_error is thrown. If @a __pos > length(),
1122 * out_of_range is thrown. The value of the string doesn't
1123 * change if an error is thrown.
1126 insert(size_type __pos
, size_type __n
, _CharT __c
)
1127 { return _M_replace_aux(_M_check(__pos
, "__versa_string::insert"),
1128 size_type(0), __n
, __c
); }
1131 * @brief Insert one character.
1132 * @param __p Iterator referencing position in string to insert at.
1133 * @param __c The character to insert.
1134 * @return Iterator referencing newly inserted char.
1135 * @throw std::length_error If new length exceeds @c max_size().
1137 * Inserts character @a __c at position referenced by @a __p.
1138 * If adding character causes the length to exceed max_size(),
1139 * length_error is thrown. If @a __p is beyond end of string,
1140 * out_of_range is thrown. The value of the string doesn't
1141 * change if an error is thrown.
1144 #if __cplusplus >= 201103L
1145 insert(const_iterator __p
, _CharT __c
)
1147 insert(iterator __p
, _CharT __c
)
1150 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
1151 const size_type __pos
= __p
- _M_ibegin();
1152 _M_replace_aux(__pos
, size_type(0), size_type(1), __c
);
1153 this->_M_set_leaked();
1154 return iterator(this->_M_data() + __pos
);
1158 * @brief Remove characters.
1159 * @param __pos Index of first character to remove (default 0).
1160 * @param __n Number of characters to remove (default remainder).
1161 * @return Reference to this string.
1162 * @throw std::out_of_range If @a __pos is beyond the end of this
1165 * Removes @a __n characters from this string starting at @a
1166 * __pos. The length of the string is reduced by @a __n. If
1167 * there are < @a __n characters to remove, the remainder of
1168 * the string is truncated. If @a __p is beyond end of string,
1169 * out_of_range is thrown. The value of the string doesn't
1170 * change if an error is thrown.
1173 erase(size_type __pos
= 0, size_type __n
= npos
)
1175 this->_M_erase(_M_check(__pos
, "__versa_string::erase"),
1176 _M_limit(__pos
, __n
));
1181 * @brief Remove one character.
1182 * @param __position Iterator referencing the character to remove.
1183 * @return iterator referencing same location after removal.
1185 * Removes the character at @a __position from this string. The
1186 * value of the string doesn't change if an error is thrown.
1189 #if __cplusplus >= 201103L
1190 erase(const_iterator __position
)
1192 erase(iterator __position
)
1195 _GLIBCXX_DEBUG_PEDASSERT(__position
>= _M_ibegin()
1196 && __position
< _M_iend());
1197 const size_type __pos
= __position
- _M_ibegin();
1198 this->_M_erase(__pos
, size_type(1));
1199 this->_M_set_leaked();
1200 return iterator(this->_M_data() + __pos
);
1204 * @brief Remove a range of characters.
1205 * @param __first Iterator referencing the first character to remove.
1206 * @param __last Iterator referencing the end of the range.
1207 * @return Iterator referencing location of first after removal.
1209 * Removes the characters in the range [first,last) from this
1210 * string. The value of the string doesn't change if an error
1214 #if __cplusplus >= 201103L
1215 erase(const_iterator __first
, const_iterator __last
)
1217 erase(iterator __first
, iterator __last
)
1220 _GLIBCXX_DEBUG_PEDASSERT(__first
>= _M_ibegin() && __first
<= __last
1221 && __last
<= _M_iend());
1222 const size_type __pos
= __first
- _M_ibegin();
1223 this->_M_erase(__pos
, __last
- __first
);
1224 this->_M_set_leaked();
1225 return iterator(this->_M_data() + __pos
);
1228 #if __cplusplus >= 201103L
1230 * @brief Remove the last character.
1232 * The string must be non-empty.
1236 { this->_M_erase(size()-1, 1); }
1240 * @brief Replace characters with value from another string.
1241 * @param __pos Index of first character to replace.
1242 * @param __n Number of characters to be replaced.
1243 * @param __str String to insert.
1244 * @return Reference to this string.
1245 * @throw std::out_of_range If @a __pos is beyond the end of this
1247 * @throw std::length_error If new length exceeds @c max_size().
1249 * Removes the characters in the range [pos,pos+n) from this
1250 * string. In place, the value of @a __str is inserted. If @a
1251 * __pos is beyond end of string, out_of_range is thrown. If
1252 * the length of the result exceeds max_size(), length_error is
1253 * thrown. The value of the string doesn't change if an error
1257 replace(size_type __pos
, size_type __n
, const __versa_string
& __str
)
1258 { return this->replace(__pos
, __n
, __str
._M_data(), __str
.size()); }
1261 * @brief Replace characters with value from another string.
1262 * @param __pos1 Index of first character to replace.
1263 * @param __n1 Number of characters to be replaced.
1264 * @param __str String to insert.
1265 * @param __pos2 Index of first character of str to use.
1266 * @param __n2 Number of characters from str to use.
1267 * @return Reference to this string.
1268 * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 >
1270 * @throw std::length_error If new length exceeds @c max_size().
1272 * Removes the characters in the range [pos1,pos1 + n) from
1273 * this string. In place, the value of @a __str is inserted.
1274 * If @a __pos is beyond end of string, out_of_range is thrown.
1275 * If the length of the result exceeds max_size(), length_error
1276 * is thrown. The value of the string doesn't change if an
1280 replace(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
1281 size_type __pos2
, size_type __n2
)
1283 return this->replace(__pos1
, __n1
, __str
._M_data()
1284 + __str
._M_check(__pos2
,
1285 "__versa_string::replace"),
1286 __str
._M_limit(__pos2
, __n2
));
1290 * @brief Replace characters with value of a C substring.
1291 * @param __pos Index of first character to replace.
1292 * @param __n1 Number of characters to be replaced.
1293 * @param __s C string to insert.
1294 * @param __n2 Number of characters from @a __s to use.
1295 * @return Reference to this string.
1296 * @throw std::out_of_range If @a __pos1 > size().
1297 * @throw std::length_error If new length exceeds @c max_size().
1299 * Removes the characters in the range [pos,pos + n1) from this
1300 * string. In place, the first @a __n2 characters of @a __s
1301 * are inserted, or all of @a __s if @a __n2 is too large. If
1302 * @a __pos is beyond end of string, out_of_range is thrown.
1303 * If the length of result exceeds max_size(), length_error is
1304 * thrown. The value of the string doesn't change if an error
1308 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
,
1311 __glibcxx_requires_string_len(__s
, __n2
);
1312 return _M_replace(_M_check(__pos
, "__versa_string::replace"),
1313 _M_limit(__pos
, __n1
), __s
, __n2
);
1317 * @brief Replace characters with value of a C string.
1318 * @param __pos Index of first character to replace.
1319 * @param __n1 Number of characters to be replaced.
1320 * @param __s C string to insert.
1321 * @return Reference to this string.
1322 * @throw std::out_of_range If @a __pos > size().
1323 * @throw std::length_error If new length exceeds @c max_size().
1325 * Removes the characters in the range [pos,pos + n1) from this
1326 * string. In place, the characters of @a __s are inserted. If
1327 * @a pos is beyond end of string, out_of_range is thrown. If
1328 * the length of result exceeds max_size(), length_error is thrown.
1329 * The value of the string doesn't change if an error is thrown.
1332 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
)
1334 __glibcxx_requires_string(__s
);
1335 return this->replace(__pos
, __n1
, __s
, traits_type::length(__s
));
1339 * @brief Replace characters with multiple characters.
1340 * @param __pos Index of first character to replace.
1341 * @param __n1 Number of characters to be replaced.
1342 * @param __n2 Number of characters to insert.
1343 * @param __c Character to insert.
1344 * @return Reference to this string.
1345 * @throw std::out_of_range If @a __pos > size().
1346 * @throw std::length_error If new length exceeds @c max_size().
1348 * Removes the characters in the range [pos,pos + n1) from this
1349 * string. In place, @a __n2 copies of @a __c are inserted.
1350 * If @a __pos is beyond end of string, out_of_range is thrown.
1351 * If the length of result exceeds max_size(), length_error is
1352 * thrown. The value of the string doesn't change if an error
1356 replace(size_type __pos
, size_type __n1
, size_type __n2
, _CharT __c
)
1357 { return _M_replace_aux(_M_check(__pos
, "__versa_string::replace"),
1358 _M_limit(__pos
, __n1
), __n2
, __c
); }
1361 * @brief Replace range of characters with string.
1362 * @param __i1 Iterator referencing start of range to replace.
1363 * @param __i2 Iterator referencing end of range to replace.
1364 * @param __str String value to insert.
1365 * @return Reference to this string.
1366 * @throw std::length_error If new length exceeds @c max_size().
1368 * Removes the characters in the range [i1,i2). In place, the
1369 * value of @a __str is inserted. If the length of result
1370 * exceeds max_size(), length_error is thrown. The value of
1371 * the string doesn't change if an error is thrown.
1374 #if __cplusplus >= 201103L
1375 replace(const_iterator __i1
, const_iterator __i2
,
1376 const __versa_string
& __str
)
1378 replace(iterator __i1
, iterator __i2
, const __versa_string
& __str
)
1380 { return this->replace(__i1
, __i2
, __str
._M_data(), __str
.size()); }
1383 * @brief Replace range of characters with C substring.
1384 * @param __i1 Iterator referencing start of range to replace.
1385 * @param __i2 Iterator referencing end of range to replace.
1386 * @param __s C string value to insert.
1387 * @param __n Number of characters from s to insert.
1388 * @return Reference to this string.
1389 * @throw std::length_error If new length exceeds @c max_size().
1391 * Removes the characters in the range [i1,i2). In place, the
1392 * first @a n characters of @a __s are inserted. If the length
1393 * of result exceeds max_size(), length_error is thrown. The
1394 * value of the string doesn't change if an error is thrown.
1397 #if __cplusplus >= 201103L
1398 replace(const_iterator __i1
, const_iterator __i2
,
1399 const _CharT
* __s
, size_type __n
)
1401 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
, size_type __n
)
1404 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1405 && __i2
<= _M_iend());
1406 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
, __s
, __n
);
1410 * @brief Replace range of characters with C string.
1411 * @param __i1 Iterator referencing start of range to replace.
1412 * @param __i2 Iterator referencing end of range to replace.
1413 * @param __s C string value to insert.
1414 * @return Reference to this string.
1415 * @throw std::length_error If new length exceeds @c max_size().
1417 * Removes the characters in the range [i1,i2). In place, the
1418 * characters of @a __s are inserted. If the length of result
1419 * exceeds max_size(), length_error is thrown. The value of
1420 * the string doesn't change if an error is thrown.
1423 #if __cplusplus >= 201103L
1424 replace(const_iterator __i1
, const_iterator __i2
, const _CharT
* __s
)
1426 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
)
1429 __glibcxx_requires_string(__s
);
1430 return this->replace(__i1
, __i2
, __s
, traits_type::length(__s
));
1434 * @brief Replace range of characters with multiple characters
1435 * @param __i1 Iterator referencing start of range to replace.
1436 * @param __i2 Iterator referencing end of range to replace.
1437 * @param __n Number of characters to insert.
1438 * @param __c Character to insert.
1439 * @return Reference to this string.
1440 * @throw std::length_error If new length exceeds @c max_size().
1442 * Removes the characters in the range [i1,i2). In place, @a
1443 * __n copies of @a __c are inserted. If the length of result
1444 * exceeds max_size(), length_error is thrown. The value of
1445 * the string doesn't change if an error is thrown.
1448 #if __cplusplus >= 201103L
1449 replace(const_iterator __i1
, const_iterator __i2
, size_type __n
,
1452 replace(iterator __i1
, iterator __i2
, size_type __n
, _CharT __c
)
1455 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1456 && __i2
<= _M_iend());
1457 return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __c
);
1461 * @brief Replace range of characters with range.
1462 * @param __i1 Iterator referencing start of range to replace.
1463 * @param __i2 Iterator referencing end of range to replace.
1464 * @param __k1 Iterator referencing start of range to insert.
1465 * @param __k2 Iterator referencing end of range to insert.
1466 * @return Reference to this string.
1467 * @throw std::length_error If new length exceeds @c max_size().
1469 * Removes the characters in the range [i1,i2). In place,
1470 * characters in the range [k1,k2) are inserted. If the length
1471 * of result exceeds max_size(), length_error is thrown. The
1472 * value of the string doesn't change if an error is thrown.
1474 #if __cplusplus >= 201103L
1475 template<class _InputIterator
,
1476 typename
= std::_RequireInputIter
<_InputIterator
>>
1478 replace(const_iterator __i1
, const_iterator __i2
,
1479 _InputIterator __k1
, _InputIterator __k2
)
1481 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1482 && __i2
<= _M_iend());
1483 __glibcxx_requires_valid_range(__k1
, __k2
);
1484 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
,
1485 std::__false_type());
1488 template<class _InputIterator
>
1490 replace(iterator __i1
, iterator __i2
,
1491 _InputIterator __k1
, _InputIterator __k2
)
1493 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1494 && __i2
<= _M_iend());
1495 __glibcxx_requires_valid_range(__k1
, __k2
);
1496 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
1497 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
, _Integral());
1501 // Specializations for the common case of pointer and iterator:
1502 // useful to avoid the overhead of temporary buffering in _M_replace.
1504 #if __cplusplus >= 201103L
1505 replace(const_iterator __i1
, const_iterator __i2
,
1506 _CharT
* __k1
, _CharT
* __k2
)
1508 replace(iterator __i1
, iterator __i2
,
1509 _CharT
* __k1
, _CharT
* __k2
)
1512 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1513 && __i2
<= _M_iend());
1514 __glibcxx_requires_valid_range(__k1
, __k2
);
1515 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1520 #if __cplusplus >= 201103L
1521 replace(const_iterator __i1
, const_iterator __i2
,
1522 const _CharT
* __k1
, const _CharT
* __k2
)
1524 replace(iterator __i1
, iterator __i2
,
1525 const _CharT
* __k1
, const _CharT
* __k2
)
1528 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1529 && __i2
<= _M_iend());
1530 __glibcxx_requires_valid_range(__k1
, __k2
);
1531 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1536 #if __cplusplus >= 201103L
1537 replace(const_iterator __i1
, const_iterator __i2
,
1538 iterator __k1
, iterator __k2
)
1540 replace(iterator __i1
, iterator __i2
,
1541 iterator __k1
, iterator __k2
)
1544 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1545 && __i2
<= _M_iend());
1546 __glibcxx_requires_valid_range(__k1
, __k2
);
1547 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1548 __k1
.base(), __k2
- __k1
);
1552 #if __cplusplus >= 201103L
1553 replace(const_iterator __i1
, const_iterator __i2
,
1554 const_iterator __k1
, const_iterator __k2
)
1556 replace(iterator __i1
, iterator __i2
,
1557 const_iterator __k1
, const_iterator __k2
)
1560 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1561 && __i2
<= _M_iend());
1562 __glibcxx_requires_valid_range(__k1
, __k2
);
1563 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1564 __k1
.base(), __k2
- __k1
);
1567 #if __cplusplus >= 201103L
1569 * @brief Replace range of characters with initializer_list.
1570 * @param __i1 Iterator referencing start of range to replace.
1571 * @param __i2 Iterator referencing end of range to replace.
1572 * @param __l The initializer_list of characters to insert.
1573 * @return Reference to this string.
1574 * @throw std::length_error If new length exceeds @c max_size().
1576 * Removes the characters in the range [i1,i2). In place,
1577 * characters in the range [k1,k2) are inserted. If the length
1578 * of result exceeds max_size(), length_error is thrown. The
1579 * value of the string doesn't change if an error is thrown.
1582 replace(const_iterator __i1
, const_iterator __i2
,
1583 std::initializer_list
<_CharT
> __l
)
1584 { return this->replace(__i1
, __i2
, __l
.begin(), __l
.end()); }
1588 template<class _Integer
>
1590 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1591 _Integer __n
, _Integer __val
, std::__true_type
)
1592 { return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __val
); }
1594 template<class _InputIterator
>
1596 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1597 _InputIterator __k1
, _InputIterator __k2
,
1601 _M_replace_aux(size_type __pos1
, size_type __n1
, size_type __n2
,
1605 _M_replace(size_type __pos
, size_type __len1
, const _CharT
* __s
,
1606 const size_type __len2
);
1609 _M_append(const _CharT
* __s
, size_type __n
);
1614 * @brief Copy substring into C string.
1615 * @param __s C string to copy value into.
1616 * @param __n Number of characters to copy.
1617 * @param __pos Index of first character to copy.
1618 * @return Number of characters actually copied
1619 * @throw std::out_of_range If pos > size().
1621 * Copies up to @a __n characters starting at @a __pos into the
1622 * C string @a s. If @a __pos is greater than size(),
1623 * out_of_range is thrown.
1626 copy(_CharT
* __s
, size_type __n
, size_type __pos
= 0) const;
1629 * @brief Swap contents with another string.
1630 * @param __s String to swap with.
1632 * Exchanges the contents of this string with that of @a __s in
1636 swap(__versa_string
& __s
) _GLIBCXX_NOEXCEPT
1637 { this->_M_swap(__s
); }
1639 // String operations:
1641 * @brief Return const pointer to null-terminated contents.
1643 * This is a handle to internal data. Do not modify or dire things may
1647 c_str() const _GLIBCXX_NOEXCEPT
1648 { return this->_M_data(); }
1651 * @brief Return const pointer to contents.
1653 * This is a handle to internal data. Do not modify or dire things may
1657 data() const _GLIBCXX_NOEXCEPT
1658 { return this->_M_data(); }
1661 * @brief Return copy of allocator used to construct this string.
1664 get_allocator() const _GLIBCXX_NOEXCEPT
1665 { return allocator_type(this->_M_get_allocator()); }
1668 * @brief Find position of a C substring.
1669 * @param __s C string to locate.
1670 * @param __pos Index of character to search from.
1671 * @param __n Number of characters from @a __s to search for.
1672 * @return Index of start of first occurrence.
1674 * Starting from @a __pos, searches forward for the first @a
1675 * __n characters in @a __s within this string. If found,
1676 * returns the index where it begins. If not found, returns
1680 find(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1683 * @brief Find position of a string.
1684 * @param __str String to locate.
1685 * @param __pos Index of character to search from (default 0).
1686 * @return Index of start of first occurrence.
1688 * Starting from @a __pos, searches forward for value of @a
1689 * __str within this string. If found, returns the index where
1690 * it begins. If not found, returns npos.
1693 find(const __versa_string
& __str
, size_type __pos
= 0) const
1695 { return this->find(__str
.data(), __pos
, __str
.size()); }
1698 * @brief Find position of a C string.
1699 * @param __s C string to locate.
1700 * @param __pos Index of character to search from (default 0).
1701 * @return Index of start of first occurrence.
1703 * Starting from @a __pos, searches forward for the value of @a
1704 * __s within this string. If found, returns the index where
1705 * it begins. If not found, returns npos.
1708 find(const _CharT
* __s
, size_type __pos
= 0) const
1710 __glibcxx_requires_string(__s
);
1711 return this->find(__s
, __pos
, traits_type::length(__s
));
1715 * @brief Find position of a character.
1716 * @param __c Character to locate.
1717 * @param __pos Index of character to search from (default 0).
1718 * @return Index of first occurrence.
1720 * Starting from @a __pos, searches forward for @a __c within
1721 * this string. If found, returns the index where it was
1722 * found. If not found, returns npos.
1725 find(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
;
1728 * @brief Find last position of a string.
1729 * @param __str String to locate.
1730 * @param __pos Index of character to search back from (default end).
1731 * @return Index of start of last occurrence.
1733 * Starting from @a __pos, searches backward for value of @a
1734 * __str within this string. If found, returns the index where
1735 * it begins. If not found, returns npos.
1738 rfind(const __versa_string
& __str
, size_type __pos
= npos
) const
1740 { return this->rfind(__str
.data(), __pos
, __str
.size()); }
1743 * @brief Find last position of a C substring.
1744 * @param __s C string to locate.
1745 * @param __pos Index of character to search back from.
1746 * @param __n Number of characters from s to search for.
1747 * @return Index of start of last occurrence.
1749 * Starting from @a __pos, searches backward for the first @a
1750 * __n characters in @a __s within this string. If found,
1751 * returns the index where it begins. If not found, returns
1755 rfind(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1758 * @brief Find last position of a C string.
1759 * @param __s C string to locate.
1760 * @param __pos Index of character to start search at (default end).
1761 * @return Index of start of last occurrence.
1763 * Starting from @a __pos, searches backward for the value of
1764 * @a __s within this string. If found, returns the index
1765 * where it begins. If not found, returns npos.
1768 rfind(const _CharT
* __s
, size_type __pos
= npos
) const
1770 __glibcxx_requires_string(__s
);
1771 return this->rfind(__s
, __pos
, traits_type::length(__s
));
1775 * @brief Find last position of a character.
1776 * @param __c Character to locate.
1777 * @param __pos Index of character to search back from (default end).
1778 * @return Index of last occurrence.
1780 * Starting from @a __pos, searches backward for @a __c within
1781 * this string. If found, returns the index where it was
1782 * found. If not found, returns npos.
1785 rfind(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
;
1788 * @brief Find position of a character of string.
1789 * @param __str String containing characters to locate.
1790 * @param __pos Index of character to search from (default 0).
1791 * @return Index of first occurrence.
1793 * Starting from @a __pos, searches forward for one of the characters of
1794 * @a __str within this string. If found, returns the index where it was
1795 * found. If not found, returns npos.
1798 find_first_of(const __versa_string
& __str
, size_type __pos
= 0) const
1800 { return this->find_first_of(__str
.data(), __pos
, __str
.size()); }
1803 * @brief Find position of a character of C substring.
1804 * @param __s String containing characters to locate.
1805 * @param __pos Index of character to search from.
1806 * @param __n Number of characters from s to search for.
1807 * @return Index of first occurrence.
1809 * Starting from @a __pos, searches forward for one of the
1810 * first @a __n characters of @a __s within this string. If
1811 * found, returns the index where it was found. If not found,
1815 find_first_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1818 * @brief Find position of a character of C string.
1819 * @param __s String containing characters to locate.
1820 * @param __pos Index of character to search from (default 0).
1821 * @return Index of first occurrence.
1823 * Starting from @a __pos, searches forward for one of the
1824 * characters of @a __s within this string. If found, returns
1825 * the index where it was found. If not found, returns npos.
1828 find_first_of(const _CharT
* __s
, size_type __pos
= 0) const
1830 __glibcxx_requires_string(__s
);
1831 return this->find_first_of(__s
, __pos
, traits_type::length(__s
));
1835 * @brief Find position of a character.
1836 * @param __c Character to locate.
1837 * @param __pos Index of character to search from (default 0).
1838 * @return Index of first occurrence.
1840 * Starting from @a __pos, searches forward for the character
1841 * @a __c within this string. If found, returns the index
1842 * where it was found. If not found, returns npos.
1844 * Note: equivalent to find(c, pos).
1847 find_first_of(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
1848 { return this->find(__c
, __pos
); }
1851 * @brief Find last position of a character of string.
1852 * @param __str String containing characters to locate.
1853 * @param __pos Index of character to search back from (default end).
1854 * @return Index of last occurrence.
1856 * Starting from @a __pos, searches backward for one of the
1857 * characters of @a __str within this string. If found,
1858 * returns the index where it was found. If not found, returns
1862 find_last_of(const __versa_string
& __str
, size_type __pos
= npos
) const
1864 { return this->find_last_of(__str
.data(), __pos
, __str
.size()); }
1867 * @brief Find last position of a character of C substring.
1868 * @param __s C string containing characters to locate.
1869 * @param __pos Index of character to search back from.
1870 * @param __n Number of characters from s to search for.
1871 * @return Index of last occurrence.
1873 * Starting from @a __pos, searches backward for one of the
1874 * first @a __n characters of @a __s within this string. If
1875 * found, returns the index where it was found. If not found,
1879 find_last_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1882 * @brief Find last position of a character of C string.
1883 * @param __s C string containing characters to locate.
1884 * @param __pos Index of character to search back from (default end).
1885 * @return Index of last occurrence.
1887 * Starting from @a __pos, searches backward for one of the
1888 * characters of @a __s within this string. If found, returns
1889 * the index where it was found. If not found, returns npos.
1892 find_last_of(const _CharT
* __s
, size_type __pos
= npos
) const
1894 __glibcxx_requires_string(__s
);
1895 return this->find_last_of(__s
, __pos
, traits_type::length(__s
));
1899 * @brief Find last position of a character.
1900 * @param __c Character to locate.
1901 * @param __pos Index of character to search back from (default end).
1902 * @return Index of last occurrence.
1904 * Starting from @a __pos, searches backward for @a __c within
1905 * this string. If found, returns the index where it was
1906 * found. If not found, returns npos.
1908 * Note: equivalent to rfind(c, pos).
1911 find_last_of(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1912 { return this->rfind(__c
, __pos
); }
1915 * @brief Find position of a character not in string.
1916 * @param __str String containing characters to avoid.
1917 * @param __pos Index of character to search from (default 0).
1918 * @return Index of first occurrence.
1920 * Starting from @a __pos, searches forward for a character not
1921 * contained in @a __str within this string. If found, returns
1922 * the index where it was found. If not found, returns npos.
1925 find_first_not_of(const __versa_string
& __str
, size_type __pos
= 0) const
1927 { return this->find_first_not_of(__str
.data(), __pos
, __str
.size()); }
1930 * @brief Find position of a character not in C substring.
1931 * @param __s C string containing characters to avoid.
1932 * @param __pos Index of character to search from.
1933 * @param __n Number of characters from s to consider.
1934 * @return Index of first occurrence.
1936 * Starting from @a __pos, searches forward for a character not
1937 * contained in the first @a __n characters of @a __s within
1938 * this string. If found, returns the index where it was
1939 * found. If not found, returns npos.
1942 find_first_not_of(const _CharT
* __s
, size_type __pos
,
1943 size_type __n
) const;
1946 * @brief Find position of a character not in C string.
1947 * @param __s C string containing characters to avoid.
1948 * @param __pos Index of character to search from (default 0).
1949 * @return Index of first occurrence.
1951 * Starting from @a __pos, searches forward for a character not
1952 * contained in @a __s within this string. If found, returns
1953 * the index where it was found. If not found, returns npos.
1956 find_first_not_of(const _CharT
* __s
, size_type __pos
= 0) const
1958 __glibcxx_requires_string(__s
);
1959 return this->find_first_not_of(__s
, __pos
, traits_type::length(__s
));
1963 * @brief Find position of a different character.
1964 * @param __c Character to avoid.
1965 * @param __pos Index of character to search from (default 0).
1966 * @return Index of first occurrence.
1968 * Starting from @a __pos, searches forward for a character
1969 * other than @a __c within this string. If found, returns the
1970 * index where it was found. If not found, returns npos.
1973 find_first_not_of(_CharT __c
, size_type __pos
= 0) const
1977 * @brief Find last position of a character not in string.
1978 * @param __str String containing characters to avoid.
1979 * @param __pos Index of character to search back from (default end).
1980 * @return Index of last occurrence.
1982 * Starting from @a __pos, searches backward for a character
1983 * not contained in @a __str within this string. If found,
1984 * returns the index where it was found. If not found, returns
1988 find_last_not_of(const __versa_string
& __str
,
1989 size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1990 { return this->find_last_not_of(__str
.data(), __pos
, __str
.size()); }
1993 * @brief Find last position of a character not in C substring.
1994 * @param __s C string containing characters to avoid.
1995 * @param __pos Index of character to search back from.
1996 * @param __n Number of characters from s to consider.
1997 * @return Index of last occurrence.
1999 * Starting from @a __pos, searches backward for a character
2000 * not contained in the first @a __n characters of @a __s
2001 * within this string. If found, returns the index where it
2002 * was found. If not found, returns npos.
2005 find_last_not_of(const _CharT
* __s
, size_type __pos
,
2006 size_type __n
) const;
2008 * @brief Find last position of a character not in C string.
2009 * @param __s C string containing characters to avoid.
2010 * @param __pos Index of character to search back from (default end).
2011 * @return Index of last occurrence.
2013 * Starting from @a __pos, searches backward for a character
2014 * not contained in @a __s within this string. If found,
2015 * returns the index where it was found. If not found, returns
2019 find_last_not_of(const _CharT
* __s
, size_type __pos
= npos
) const
2021 __glibcxx_requires_string(__s
);
2022 return this->find_last_not_of(__s
, __pos
, traits_type::length(__s
));
2026 * @brief Find last position of a different character.
2027 * @param __c Character to avoid.
2028 * @param __pos Index of character to search back from (default end).
2029 * @return Index of last occurrence.
2031 * Starting from @a __pos, searches backward for a character
2032 * other than @a __c within this string. If found, returns the
2033 * index where it was found. If not found, returns npos.
2036 find_last_not_of(_CharT __c
, size_type __pos
= npos
) const
2040 * @brief Get a substring.
2041 * @param __pos Index of first character (default 0).
2042 * @param __n Number of characters in substring (default remainder).
2043 * @return The new string.
2044 * @throw std::out_of_range If pos > size().
2046 * Construct and return a new string using the @a __n
2047 * characters starting at @a __pos. If the string is too
2048 * short, use the remainder of the characters. If @a __pos is
2049 * beyond the end of the string, out_of_range is thrown.
2052 substr(size_type __pos
= 0, size_type __n
= npos
) const
2054 return __versa_string(*this, _M_check(__pos
, "__versa_string::substr"),
2059 * @brief Compare to a string.
2060 * @param __str String to compare against.
2061 * @return Integer < 0, 0, or > 0.
2063 * Returns an integer < 0 if this string is ordered before @a
2064 * __str, 0 if their values are equivalent, or > 0 if this
2065 * string is ordered after @a __str. Determines the effective
2066 * length rlen of the strings to compare as the smallest of
2067 * size() and str.size(). The function then compares the two
2068 * strings by calling traits::compare(data(), str.data(),rlen).
2069 * If the result of the comparison is nonzero returns it,
2070 * otherwise the shorter one is ordered first.
2073 compare(const __versa_string
& __str
) const
2075 if (this->_M_compare(__str
))
2078 const size_type __size
= this->size();
2079 const size_type __osize
= __str
.size();
2080 const size_type __len
= std::min(__size
, __osize
);
2082 int __r
= traits_type::compare(this->_M_data(), __str
.data(), __len
);
2084 __r
= this->_S_compare(__size
, __osize
);
2089 * @brief Compare substring to a string.
2090 * @param __pos Index of first character of substring.
2091 * @param __n Number of characters in substring.
2092 * @param __str String to compare against.
2093 * @return Integer < 0, 0, or > 0.
2095 * Form the substring of this string from the @a __n characters
2096 * starting at @a __pos. Returns an integer < 0 if the
2097 * substring is ordered before @a __str, 0 if their values are
2098 * equivalent, or > 0 if the substring is ordered after @a
2099 * __str. Determines the effective length rlen of the strings
2100 * to compare as the smallest of the length of the substring
2101 * and @a __str.size(). The function then compares the two
2102 * strings by calling
2103 * traits::compare(substring.data(),str.data(),rlen). If the
2104 * result of the comparison is nonzero returns it, otherwise
2105 * the shorter one is ordered first.
2108 compare(size_type __pos
, size_type __n
,
2109 const __versa_string
& __str
) const;
2112 * @brief Compare substring to a substring.
2113 * @param __pos1 Index of first character of substring.
2114 * @param __n1 Number of characters in substring.
2115 * @param __str String to compare against.
2116 * @param __pos2 Index of first character of substring of str.
2117 * @param __n2 Number of characters in substring of str.
2118 * @return Integer < 0, 0, or > 0.
2120 * Form the substring of this string from the @a __n1
2121 * characters starting at @a __pos1. Form the substring of @a
2122 * __str from the @a __n2 characters starting at @a __pos2.
2123 * Returns an integer < 0 if this substring is ordered before
2124 * the substring of @a __str, 0 if their values are equivalent,
2125 * or > 0 if this substring is ordered after the substring of
2126 * @a __str. Determines the effective length rlen of the
2127 * strings to compare as the smallest of the lengths of the
2128 * substrings. The function then compares the two strings by
2130 * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
2131 * If the result of the comparison is nonzero returns it,
2132 * otherwise the shorter one is ordered first.
2135 compare(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
2136 size_type __pos2
, size_type __n2
) const;
2139 * @brief Compare to a C string.
2140 * @param __s C string to compare against.
2141 * @return Integer < 0, 0, or > 0.
2143 * Returns an integer < 0 if this string is ordered before @a
2144 * __s, 0 if their values are equivalent, or > 0 if this string
2145 * is ordered after @a __s. Determines the effective length
2146 * rlen of the strings to compare as the smallest of size() and
2147 * the length of a string constructed from @a __s. The
2148 * function then compares the two strings by calling
2149 * traits::compare(data(),s,rlen). If the result of the
2150 * comparison is nonzero returns it, otherwise the shorter one
2154 compare(const _CharT
* __s
) const;
2156 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2157 // 5 String::compare specification questionable
2159 * @brief Compare substring to a C string.
2160 * @param __pos Index of first character of substring.
2161 * @param __n1 Number of characters in substring.
2162 * @param __s C string to compare against.
2163 * @return Integer < 0, 0, or > 0.
2165 * Form the substring of this string from the @a __n1
2166 * characters starting at @a __pos. Returns an integer < 0 if
2167 * the substring is ordered before @a __s, 0 if their values
2168 * are equivalent, or > 0 if the substring is ordered after @a
2169 * __s. Determines the effective length rlen of the strings to
2170 * compare as the smallest of the length of the substring and
2171 * the length of a string constructed from @a __s. The
2172 * function then compares the two string by calling
2173 * traits::compare(substring.data(),s,rlen). If the result of
2174 * the comparison is nonzero returns it, otherwise the shorter
2175 * one is ordered first.
2178 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
) const;
2181 * @brief Compare substring against a character array.
2182 * @param __pos Index of first character of substring.
2183 * @param __n1 Number of characters in substring.
2184 * @param __s character array to compare against.
2185 * @param __n2 Number of characters of s.
2186 * @return Integer < 0, 0, or > 0.
2188 * Form the substring of this string from the @a __n1
2189 * characters starting at @a __pos. Form a string from the
2190 * first @a __n2 characters of @a __s. Returns an integer < 0
2191 * if this substring is ordered before the string from @a __s,
2192 * 0 if their values are equivalent, or > 0 if this substring
2193 * is ordered after the string from @a __s. Determines the
2194 * effective length rlen of the strings to compare as the
2195 * smallest of the length of the substring and @a __n2. The
2196 * function then compares the two strings by calling
2197 * traits::compare(substring.data(),__s,rlen). If the result of
2198 * the comparison is nonzero returns it, otherwise the shorter
2199 * one is ordered first.
2201 * NB: __s must have at least n2 characters, <em>\\0</em> has no special
2205 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
,
2206 size_type __n2
) const;
2211 * @brief Concatenate two strings.
2212 * @param __lhs First string.
2213 * @param __rhs Last string.
2214 * @return New string with value of @a __lhs followed by @a __rhs.
2216 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2217 template <typename
, typename
, typename
> class _Base
>
2218 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2219 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2220 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2223 * @brief Concatenate C string and string.
2224 * @param __lhs First string.
2225 * @param __rhs Last string.
2226 * @return New string with value of @a __lhs followed by @a __rhs.
2228 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2229 template <typename
, typename
, typename
> class _Base
>
2230 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2231 operator+(const _CharT
* __lhs
,
2232 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2235 * @brief Concatenate character and string.
2236 * @param __lhs First string.
2237 * @param __rhs Last string.
2238 * @return New string with @a __lhs followed by @a __rhs.
2240 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2241 template <typename
, typename
, typename
> class _Base
>
2242 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2243 operator+(_CharT __lhs
,
2244 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2247 * @brief Concatenate string and C string.
2248 * @param __lhs First string.
2249 * @param __rhs Last string.
2250 * @return New string with @a __lhs followed by @a __rhs.
2252 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2253 template <typename
, typename
, typename
> class _Base
>
2254 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2255 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2256 const _CharT
* __rhs
);
2259 * @brief Concatenate string and character.
2260 * @param __lhs First string.
2261 * @param __rhs Last string.
2262 * @return New string with @a __lhs followed by @a __rhs.
2264 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2265 template <typename
, typename
, typename
> class _Base
>
2266 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2267 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2270 #if __cplusplus >= 201103L
2271 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2272 template <typename
, typename
, typename
> class _Base
>
2273 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2274 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2275 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2276 { return std::move(__lhs
.append(__rhs
)); }
2278 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2279 template <typename
, typename
, typename
> class _Base
>
2280 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2281 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2282 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2283 { return std::move(__rhs
.insert(0, __lhs
)); }
2285 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2286 template <typename
, typename
, typename
> class _Base
>
2287 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2288 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2289 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2291 const auto __size
= __lhs
.size() + __rhs
.size();
2292 const bool __cond
= (__size
> __lhs
.capacity()
2293 && __size
<= __rhs
.capacity());
2294 return __cond
? std::move(__rhs
.insert(0, __lhs
))
2295 : std::move(__lhs
.append(__rhs
));
2298 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2299 template <typename
, typename
, typename
> class _Base
>
2300 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2301 operator+(const _CharT
* __lhs
,
2302 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2303 { return std::move(__rhs
.insert(0, __lhs
)); }
2305 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2306 template <typename
, typename
, typename
> class _Base
>
2307 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2308 operator+(_CharT __lhs
,
2309 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2310 { return std::move(__rhs
.insert(0, 1, __lhs
)); }
2312 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2313 template <typename
, typename
, typename
> class _Base
>
2314 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2315 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2316 const _CharT
* __rhs
)
2317 { return std::move(__lhs
.append(__rhs
)); }
2319 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2320 template <typename
, typename
, typename
> class _Base
>
2321 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2322 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2324 { return std::move(__lhs
.append(1, __rhs
)); }
2329 * @brief Test equivalence of two strings.
2330 * @param __lhs First string.
2331 * @param __rhs Second string.
2332 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2334 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2335 template <typename
, typename
, typename
> class _Base
>
2337 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2338 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2339 { return __lhs
.compare(__rhs
) == 0; }
2341 template<typename _CharT
,
2342 template <typename
, typename
, typename
> class _Base
>
2343 inline typename __enable_if
<std::__is_char
<_CharT
>::__value
, bool>::__type
2344 operator==(const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2345 std::allocator
<_CharT
>, _Base
>& __lhs
,
2346 const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2347 std::allocator
<_CharT
>, _Base
>& __rhs
)
2348 { return (__lhs
.size() == __rhs
.size()
2349 && !std::char_traits
<_CharT
>::compare(__lhs
.data(), __rhs
.data(),
2353 * @brief Test equivalence of C string and string.
2354 * @param __lhs C string.
2355 * @param __rhs String.
2356 * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise.
2358 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2359 template <typename
, typename
, typename
> class _Base
>
2361 operator==(const _CharT
* __lhs
,
2362 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2363 { return __rhs
.compare(__lhs
) == 0; }
2366 * @brief Test equivalence of string and C string.
2367 * @param __lhs String.
2368 * @param __rhs C string.
2369 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2371 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2372 template <typename
, typename
, typename
> class _Base
>
2374 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2375 const _CharT
* __rhs
)
2376 { return __lhs
.compare(__rhs
) == 0; }
2380 * @brief Test difference of two strings.
2381 * @param __lhs First string.
2382 * @param __rhs Second string.
2383 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2385 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2386 template <typename
, typename
, typename
> class _Base
>
2388 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2389 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2390 { return !(__lhs
== __rhs
); }
2393 * @brief Test difference of C string and string.
2394 * @param __lhs C string.
2395 * @param __rhs String.
2396 * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise.
2398 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2399 template <typename
, typename
, typename
> class _Base
>
2401 operator!=(const _CharT
* __lhs
,
2402 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2403 { return !(__lhs
== __rhs
); }
2406 * @brief Test difference of string and C string.
2407 * @param __lhs String.
2408 * @param __rhs C string.
2409 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2411 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2412 template <typename
, typename
, typename
> class _Base
>
2414 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2415 const _CharT
* __rhs
)
2416 { return !(__lhs
== __rhs
); }
2420 * @brief Test if string precedes string.
2421 * @param __lhs First string.
2422 * @param __rhs Second string.
2423 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2425 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2426 template <typename
, typename
, typename
> class _Base
>
2428 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2429 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2430 { return __lhs
.compare(__rhs
) < 0; }
2433 * @brief Test if string precedes C string.
2434 * @param __lhs String.
2435 * @param __rhs C string.
2436 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2438 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2439 template <typename
, typename
, typename
> class _Base
>
2441 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2442 const _CharT
* __rhs
)
2443 { return __lhs
.compare(__rhs
) < 0; }
2446 * @brief Test if C string precedes string.
2447 * @param __lhs C string.
2448 * @param __rhs String.
2449 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2451 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2452 template <typename
, typename
, typename
> class _Base
>
2454 operator<(const _CharT
* __lhs
,
2455 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2456 { return __rhs
.compare(__lhs
) > 0; }
2460 * @brief Test if string follows string.
2461 * @param __lhs First string.
2462 * @param __rhs Second string.
2463 * @return True if @a __lhs follows @a __rhs. False otherwise.
2465 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2466 template <typename
, typename
, typename
> class _Base
>
2468 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2469 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2470 { return __lhs
.compare(__rhs
) > 0; }
2473 * @brief Test if string follows C string.
2474 * @param __lhs String.
2475 * @param __rhs C string.
2476 * @return True if @a __lhs follows @a __rhs. False otherwise.
2478 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2479 template <typename
, typename
, typename
> class _Base
>
2481 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2482 const _CharT
* __rhs
)
2483 { return __lhs
.compare(__rhs
) > 0; }
2486 * @brief Test if C string follows string.
2487 * @param __lhs C string.
2488 * @param __rhs String.
2489 * @return True if @a __lhs follows @a __rhs. False otherwise.
2491 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2492 template <typename
, typename
, typename
> class _Base
>
2494 operator>(const _CharT
* __lhs
,
2495 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2496 { return __rhs
.compare(__lhs
) < 0; }
2500 * @brief Test if string doesn't follow string.
2501 * @param __lhs First string.
2502 * @param __rhs Second string.
2503 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2505 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2506 template <typename
, typename
, typename
> class _Base
>
2508 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2509 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2510 { return __lhs
.compare(__rhs
) <= 0; }
2513 * @brief Test if string doesn't follow C string.
2514 * @param __lhs String.
2515 * @param __rhs C string.
2516 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2518 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2519 template <typename
, typename
, typename
> class _Base
>
2521 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2522 const _CharT
* __rhs
)
2523 { return __lhs
.compare(__rhs
) <= 0; }
2526 * @brief Test if C string doesn't follow string.
2527 * @param __lhs C string.
2528 * @param __rhs String.
2529 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2531 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2532 template <typename
, typename
, typename
> class _Base
>
2534 operator<=(const _CharT
* __lhs
,
2535 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2536 { return __rhs
.compare(__lhs
) >= 0; }
2540 * @brief Test if string doesn't precede string.
2541 * @param __lhs First string.
2542 * @param __rhs Second string.
2543 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2545 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2546 template <typename
, typename
, typename
> class _Base
>
2548 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2549 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2550 { return __lhs
.compare(__rhs
) >= 0; }
2553 * @brief Test if string doesn't precede C string.
2554 * @param __lhs String.
2555 * @param __rhs C string.
2556 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2558 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2559 template <typename
, typename
, typename
> class _Base
>
2561 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2562 const _CharT
* __rhs
)
2563 { return __lhs
.compare(__rhs
) >= 0; }
2566 * @brief Test if C string doesn't precede string.
2567 * @param __lhs C string.
2568 * @param __rhs String.
2569 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2571 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2572 template <typename
, typename
, typename
> class _Base
>
2574 operator>=(const _CharT
* __lhs
,
2575 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2576 { return __rhs
.compare(__lhs
) <= 0; }
2579 * @brief Swap contents of two strings.
2580 * @param __lhs First string.
2581 * @param __rhs Second string.
2583 * Exchanges the contents of @a __lhs and @a __rhs in constant time.
2585 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2586 template <typename
, typename
, typename
> class _Base
>
2588 swap(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2589 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2590 { __lhs
.swap(__rhs
); }
2592 _GLIBCXX_END_NAMESPACE_VERSION
2595 namespace std
_GLIBCXX_VISIBILITY(default)
2597 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2600 * @brief Read stream into a string.
2601 * @param __is Input stream.
2602 * @param __str Buffer to store into.
2603 * @return Reference to the input stream.
2605 * Stores characters from @a __is into @a __str until whitespace is
2606 * found, the end of the stream is encountered, or str.max_size()
2607 * is reached. If is.width() is non-zero, that is the limit on the
2608 * number of characters stored into @a __str. Any previous
2609 * contents of @a __str are erased.
2611 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2612 template <typename
, typename
, typename
> class _Base
>
2613 basic_istream
<_CharT
, _Traits
>&
2614 operator>>(basic_istream
<_CharT
, _Traits
>& __is
,
2615 __gnu_cxx::__versa_string
<_CharT
, _Traits
,
2616 _Alloc
, _Base
>& __str
);
2619 * @brief Write string to a stream.
2620 * @param __os Output stream.
2621 * @param __str String to write out.
2622 * @return Reference to the output stream.
2624 * Output characters of @a __str into os following the same rules as for
2625 * writing a C string.
2627 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2628 template <typename
, typename
, typename
> class _Base
>
2629 inline basic_ostream
<_CharT
, _Traits
>&
2630 operator<<(basic_ostream
<_CharT
, _Traits
>& __os
,
2631 const __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
,
2634 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2635 // 586. string inserter not a formatted function
2636 return __ostream_insert(__os
, __str
.data(), __str
.size());
2640 * @brief Read a line from stream into a string.
2641 * @param __is Input stream.
2642 * @param __str Buffer to store into.
2643 * @param __delim Character marking end of line.
2644 * @return Reference to the input stream.
2646 * Stores characters from @a __is into @a __str until @a __delim is
2647 * found, the end of the stream is encountered, or str.max_size()
2648 * is reached. If is.width() is non-zero, that is the limit on the
2649 * number of characters stored into @a __str. Any previous
2650 * contents of @a __str are erased. If @a delim was encountered,
2651 * it is extracted but not stored into @a __str.
2653 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2654 template <typename
, typename
, typename
> class _Base
>
2655 basic_istream
<_CharT
, _Traits
>&
2656 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2657 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
,
2661 * @brief Read a line from stream into a string.
2662 * @param __is Input stream.
2663 * @param __str Buffer to store into.
2664 * @return Reference to the input stream.
2666 * Stores characters from is into @a __str until '\n' is
2667 * found, the end of the stream is encountered, or str.max_size()
2668 * is reached. If is.width() is non-zero, that is the limit on the
2669 * number of characters stored into @a __str. Any previous
2670 * contents of @a __str are erased. If end of line was
2671 * encountered, it is extracted but not stored into @a __str.
2673 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2674 template <typename
, typename
, typename
> class _Base
>
2675 inline basic_istream
<_CharT
, _Traits
>&
2676 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2677 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
)
2678 { return getline(__is
, __str
, __is
.widen('\n')); }
2680 _GLIBCXX_END_NAMESPACE_VERSION
2683 #if __cplusplus >= 201103L
2685 #include <ext/string_conversions.h>
2687 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
2689 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2691 #if _GLIBCXX_USE_C99_STDLIB
2692 // 21.4 Numeric Conversions [string.conversions].
2694 stoi(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2695 { return __gnu_cxx::__stoa
<long, int>(&std::strtol
, "stoi", __str
.c_str(),
2699 stol(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2700 { return __gnu_cxx::__stoa(&std::strtol
, "stol", __str
.c_str(),
2703 inline unsigned long
2704 stoul(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2705 { return __gnu_cxx::__stoa(&std::strtoul
, "stoul", __str
.c_str(),
2709 stoll(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2710 { return __gnu_cxx::__stoa(&std::strtoll
, "stoll", __str
.c_str(),
2713 inline unsigned long long
2714 stoull(const __vstring
& __str
, std::size_t* __idx
, int __base
= 10)
2715 { return __gnu_cxx::__stoa(&std::strtoull
, "stoull", __str
.c_str(),
2718 // NB: strtof vs strtod.
2720 stof(const __vstring
& __str
, std::size_t* __idx
= 0)
2721 { return __gnu_cxx::__stoa(&std::strtof
, "stof", __str
.c_str(), __idx
); }
2724 stod(const __vstring
& __str
, std::size_t* __idx
= 0)
2725 { return __gnu_cxx::__stoa(&std::strtod
, "stod", __str
.c_str(), __idx
); }
2728 stold(const __vstring
& __str
, std::size_t* __idx
= 0)
2729 { return __gnu_cxx::__stoa(&std::strtold
, "stold", __str
.c_str(), __idx
); }
2730 #endif // _GLIBCXX_USE_C99_STDLIB
2732 #if _GLIBCXX_USE_C99_STDIO
2733 // NB: (v)snprintf vs sprintf.
2737 to_string(int __val
)
2738 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, 4 * sizeof(int),
2742 to_string(unsigned __val
)
2743 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2744 4 * sizeof(unsigned),
2748 to_string(long __val
)
2749 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2754 to_string(unsigned long __val
)
2755 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2756 4 * sizeof(unsigned long),
2761 to_string(long long __val
)
2762 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2763 4 * sizeof(long long),
2767 to_string(unsigned long long __val
)
2768 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2769 4 * sizeof(unsigned long long),
2773 to_string(float __val
)
2775 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2776 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2781 to_string(double __val
)
2783 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2784 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2789 to_string(long double __val
)
2791 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2792 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2795 #endif // _GLIBCXX_USE_C99_STDIO
2797 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
2799 stoi(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2800 { return __gnu_cxx::__stoa
<long, int>(&std::wcstol
, "stoi", __str
.c_str(),
2804 stol(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2805 { return __gnu_cxx::__stoa(&std::wcstol
, "stol", __str
.c_str(),
2808 inline unsigned long
2809 stoul(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2810 { return __gnu_cxx::__stoa(&std::wcstoul
, "stoul", __str
.c_str(),
2814 stoll(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2815 { return __gnu_cxx::__stoa(&std::wcstoll
, "stoll", __str
.c_str(),
2818 inline unsigned long long
2819 stoull(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2820 { return __gnu_cxx::__stoa(&std::wcstoull
, "stoull", __str
.c_str(),
2823 // NB: wcstof vs wcstod.
2825 stof(const __wvstring
& __str
, std::size_t* __idx
= 0)
2826 { return __gnu_cxx::__stoa(&std::wcstof
, "stof", __str
.c_str(), __idx
); }
2829 stod(const __wvstring
& __str
, std::size_t* __idx
= 0)
2830 { return __gnu_cxx::__stoa(&std::wcstod
, "stod", __str
.c_str(), __idx
); }
2833 stold(const __wvstring
& __str
, std::size_t* __idx
= 0)
2834 { return __gnu_cxx::__stoa(&std::wcstold
, "stold", __str
.c_str(), __idx
); }
2836 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2839 to_wstring(int __val
)
2840 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2845 to_wstring(unsigned __val
)
2846 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2847 4 * sizeof(unsigned),
2851 to_wstring(long __val
)
2852 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2857 to_wstring(unsigned long __val
)
2858 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2859 4 * sizeof(unsigned long),
2863 to_wstring(long long __val
)
2864 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2865 4 * sizeof(long long),
2869 to_wstring(unsigned long long __val
)
2870 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2871 4 * sizeof(unsigned long long),
2875 to_wstring(float __val
)
2877 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2878 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2883 to_wstring(double __val
)
2885 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2886 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2891 to_wstring(long double __val
)
2893 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2894 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2897 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2898 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
2900 _GLIBCXX_END_NAMESPACE_VERSION
2905 #if __cplusplus >= 201103L
2907 #include <bits/functional_hash.h>
2909 namespace std
_GLIBCXX_VISIBILITY(default)
2911 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2913 /// std::hash specialization for __vstring.
2915 struct hash
<__gnu_cxx::__vstring
>
2916 : public __hash_base
<size_t, __gnu_cxx::__vstring
>
2919 operator()(const __gnu_cxx::__vstring
& __s
) const noexcept
2920 { return std::_Hash_impl::hash(__s
.data(), __s
.length()); }
2923 #ifdef _GLIBCXX_USE_WCHAR_T
2924 /// std::hash specialization for __wvstring.
2926 struct hash
<__gnu_cxx::__wvstring
>
2927 : public __hash_base
<size_t, __gnu_cxx::__wvstring
>
2930 operator()(const __gnu_cxx::__wvstring
& __s
) const noexcept
2931 { return std::_Hash_impl::hash(__s
.data(),
2932 __s
.length() * sizeof(wchar_t)); }
2936 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
2937 /// std::hash specialization for __u16vstring.
2939 struct hash
<__gnu_cxx::__u16vstring
>
2940 : public __hash_base
<size_t, __gnu_cxx::__u16vstring
>
2943 operator()(const __gnu_cxx::__u16vstring
& __s
) const noexcept
2944 { return std::_Hash_impl::hash(__s
.data(),
2945 __s
.length() * sizeof(char16_t
)); }
2948 /// std::hash specialization for __u32vstring.
2950 struct hash
<__gnu_cxx::__u32vstring
>
2951 : public __hash_base
<size_t, __gnu_cxx::__u32vstring
>
2954 operator()(const __gnu_cxx::__u32vstring
& __s
) const noexcept
2955 { return std::_Hash_impl::hash(__s
.data(),
2956 __s
.length() * sizeof(char32_t
)); }
2960 _GLIBCXX_END_NAMESPACE_VERSION
2965 #include "vstring.tcc"
2967 #endif /* _VSTRING_H */