1 // Versatile string -*- C++ -*-
3 // Copyright (C) 2005-2021 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
;
61 typedef __alloc_traits
<_CharT_alloc_type
> _CharT_alloc_traits
;
65 typedef _Traits traits_type
;
66 typedef typename
_Traits::char_type value_type
;
67 typedef _Alloc allocator_type
;
68 typedef typename
_CharT_alloc_type::size_type size_type
;
69 typedef typename
_CharT_alloc_type::difference_type difference_type
;
70 typedef value_type
& reference
;
71 typedef const value_type
& const_reference
;
72 typedef typename
_CharT_alloc_traits::pointer pointer
;
73 typedef typename
_CharT_alloc_traits::const_pointer const_pointer
;
74 typedef __gnu_cxx::__normal_iterator
<pointer
, __versa_string
> iterator
;
75 typedef __gnu_cxx::__normal_iterator
<const_pointer
, __versa_string
>
77 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
78 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
80 // Data Member (public):
81 /// Value returned by various member functions when they fail.
82 static const size_type npos
= static_cast<size_type
>(-1);
86 _M_check(size_type __pos
, const char* __s
) const
88 if (__pos
> this->size())
89 std::__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
90 "this->size() (which is %zu)"),
91 __s
, __pos
, this->size());
96 _M_check_length(size_type __n1
, size_type __n2
, const char* __s
) const
98 if (this->max_size() - (this->size() - __n1
) < __n2
)
99 std::__throw_length_error(__N(__s
));
102 // NB: _M_limit doesn't check for a bad __pos value.
104 _M_limit(size_type __pos
, size_type __off
) const _GLIBCXX_NOEXCEPT
106 const bool __testoff
= __off
< this->size() - __pos
;
107 return __testoff
? __off
: this->size() - __pos
;
110 // True if _Rep and source do not overlap.
112 _M_disjunct(const _CharT
* __s
) const _GLIBCXX_NOEXCEPT
114 return (std::less
<const _CharT
*>()(__s
, this->_M_data())
115 || std::less
<const _CharT
*>()(this->_M_data()
116 + this->size(), __s
));
119 // For the internal use we have functions similar to `begin'/`end'
120 // but they do not call _M_leak.
122 _M_ibegin() const _GLIBCXX_NOEXCEPT
123 { return iterator(this->_M_data()); }
126 _M_iend() const _GLIBCXX_NOEXCEPT
127 { return iterator(this->_M_data() + this->_M_length()); }
130 // Construct/copy/destroy:
131 // NB: We overload ctors in some cases instead of using default
132 // arguments, per 17.4.4.4 para. 2 item 2.
135 * @brief Construct an empty string using allocator @a a.
138 __versa_string(const _Alloc
& __a
= _Alloc()) _GLIBCXX_NOEXCEPT
139 : __vstring_base(__a
) { }
141 // NB: per LWG issue 42, semantics different from IS:
143 * @brief Construct string with copy of value of @a __str.
144 * @param __str Source string.
146 __versa_string(const __versa_string
& __str
)
147 : __vstring_base(__str
) { }
149 #if __cplusplus >= 201103L
151 * @brief String move constructor.
152 * @param __str Source string.
154 * The newly-constructed %string contains the exact contents of
155 * @a __str. The contents of @a __str are a valid, but unspecified
158 __versa_string(__versa_string
&& __str
) noexcept
159 : __vstring_base(std::move(__str
)) { }
162 * @brief Construct string from an initializer list.
163 * @param __l std::initializer_list of characters.
164 * @param __a Allocator to use (default is default allocator).
166 __versa_string(std::initializer_list
<_CharT
> __l
,
167 const _Alloc
& __a
= _Alloc())
168 : __vstring_base(__l
.begin(), __l
.end(), __a
) { }
172 * @brief Construct string as copy of a substring.
173 * @param __str Source string.
174 * @param __pos Index of first character to copy from.
175 * @param __n Number of characters to copy (default remainder).
177 __versa_string(const __versa_string
& __str
, size_type __pos
,
178 size_type __n
= npos
)
179 : __vstring_base(__str
._M_data()
180 + __str
._M_check(__pos
,
181 "__versa_string::__versa_string"),
182 __str
._M_data() + __str
._M_limit(__pos
, __n
)
183 + __pos
, _Alloc()) { }
186 * @brief Construct string as copy of a substring.
187 * @param __str Source string.
188 * @param __pos Index of first character to copy from.
189 * @param __n Number of characters to copy.
190 * @param __a Allocator to use.
192 __versa_string(const __versa_string
& __str
, size_type __pos
,
193 size_type __n
, const _Alloc
& __a
)
194 : __vstring_base(__str
._M_data()
195 + __str
._M_check(__pos
,
196 "__versa_string::__versa_string"),
197 __str
._M_data() + __str
._M_limit(__pos
, __n
)
201 * @brief Construct string initialized by a character array.
202 * @param __s Source character array.
203 * @param __n Number of characters to copy.
204 * @param __a Allocator to use (default is default allocator).
206 * NB: @a __s must have at least @a __n characters, '\\0' has no special
209 __versa_string(const _CharT
* __s
, size_type __n
,
210 const _Alloc
& __a
= _Alloc())
211 : __vstring_base(__s
, __s
+ __n
, __a
) { }
214 * @brief Construct string as copy of a C string.
215 * @param __s Source C string.
216 * @param __a Allocator to use (default is default allocator).
218 __versa_string(const _CharT
* __s
, const _Alloc
& __a
= _Alloc())
219 : __vstring_base(__s
, __s
? __s
+ traits_type::length(__s
) :
223 * @brief Construct string as multiple characters.
224 * @param __n Number of characters.
225 * @param __c Character to use.
226 * @param __a Allocator to use (default is default allocator).
228 __versa_string(size_type __n
, _CharT __c
, const _Alloc
& __a
= _Alloc())
229 : __vstring_base(__n
, __c
, __a
) { }
232 * @brief Construct string as copy of a range.
233 * @param __beg Start of range.
234 * @param __end End of range.
235 * @param __a Allocator to use (default is default allocator).
237 #if __cplusplus >= 201103L
238 template<class _InputIterator
,
239 typename
= std::_RequireInputIter
<_InputIterator
>>
241 template<class _InputIterator
>
243 __versa_string(_InputIterator __beg
, _InputIterator __end
,
244 const _Alloc
& __a
= _Alloc())
245 : __vstring_base(__beg
, __end
, __a
) { }
248 * @brief Destroy the string instance.
250 ~__versa_string() _GLIBCXX_NOEXCEPT
{ }
253 * @brief Assign the value of @a str to this string.
254 * @param __str Source string.
257 operator=(const __versa_string
& __str
)
258 { return this->assign(__str
); }
260 #if __cplusplus >= 201103L
262 * @brief String move assignment operator.
263 * @param __str Source string.
265 * The contents of @a __str are moved into this string (without
266 * copying). @a __str is a valid, but unspecified string.
269 operator=(__versa_string
&& __str
) noexcept
277 * @brief Set value to string constructed from initializer list.
278 * @param __l std::initializer_list.
281 operator=(std::initializer_list
<_CharT
> __l
)
283 this->assign(__l
.begin(), __l
.end());
289 * @brief Copy contents of @a __s into this string.
290 * @param __s Source null-terminated string.
293 operator=(const _CharT
* __s
)
294 { return this->assign(__s
); }
297 * @brief Set value to string of length 1.
298 * @param __c Source character.
300 * Assigning to a character makes this string length 1 and
301 * (*this)[0] == @a __c.
304 operator=(_CharT __c
)
306 this->assign(1, __c
);
312 * Returns a read/write iterator that points to the first character in
313 * the %string. Unshares the string.
316 begin() _GLIBCXX_NOEXCEPT
319 return iterator(this->_M_data());
323 * Returns a read-only (constant) iterator that points to the first
324 * character in the %string.
327 begin() const _GLIBCXX_NOEXCEPT
328 { return const_iterator(this->_M_data()); }
331 * Returns a read/write iterator that points one past the last
332 * character in the %string. Unshares the string.
335 end() _GLIBCXX_NOEXCEPT
338 return iterator(this->_M_data() + this->size());
342 * Returns a read-only (constant) iterator that points one past the
343 * last character in the %string.
346 end() const _GLIBCXX_NOEXCEPT
347 { return const_iterator(this->_M_data() + this->size()); }
350 * Returns a read/write reverse iterator that points to the last
351 * character in the %string. Iteration is done in reverse element
352 * order. Unshares the string.
355 rbegin() _GLIBCXX_NOEXCEPT
356 { return reverse_iterator(this->end()); }
359 * Returns a read-only (constant) reverse iterator that points
360 * to the last character in the %string. Iteration is done in
361 * reverse element order.
363 const_reverse_iterator
364 rbegin() const _GLIBCXX_NOEXCEPT
365 { return const_reverse_iterator(this->end()); }
368 * Returns a read/write reverse iterator that points to one before the
369 * first character in the %string. Iteration is done in reverse
370 * element order. Unshares the string.
373 rend() _GLIBCXX_NOEXCEPT
374 { return reverse_iterator(this->begin()); }
377 * Returns a read-only (constant) reverse iterator that points
378 * to one before the first character in the %string. Iteration
379 * is done in reverse element order.
381 const_reverse_iterator
382 rend() const _GLIBCXX_NOEXCEPT
383 { return const_reverse_iterator(this->begin()); }
385 #if __cplusplus >= 201103L
387 * Returns a read-only (constant) iterator that points to the first
388 * character in the %string.
391 cbegin() const noexcept
392 { return const_iterator(this->_M_data()); }
395 * Returns a read-only (constant) iterator that points one past the
396 * last character in the %string.
399 cend() const noexcept
400 { return const_iterator(this->_M_data() + this->size()); }
403 * Returns a read-only (constant) reverse iterator that points
404 * to the last character in the %string. Iteration is done in
405 * reverse element order.
407 const_reverse_iterator
408 crbegin() const noexcept
409 { return const_reverse_iterator(this->end()); }
412 * Returns a read-only (constant) reverse iterator that points
413 * to one before the first character in the %string. Iteration
414 * is done in reverse element order.
416 const_reverse_iterator
417 crend() const noexcept
418 { return const_reverse_iterator(this->begin()); }
423 /// Returns the number of characters in the string, not including any
424 /// null-termination.
426 size() const _GLIBCXX_NOEXCEPT
427 { return this->_M_length(); }
429 /// Returns the number of characters in the string, not including any
430 /// null-termination.
432 length() const _GLIBCXX_NOEXCEPT
433 { return this->_M_length(); }
435 /// Returns the size() of the largest possible %string.
437 max_size() const _GLIBCXX_NOEXCEPT
438 { return this->_M_max_size(); }
441 * @brief Resizes the %string to the specified number of characters.
442 * @param __n Number of characters the %string should contain.
443 * @param __c Character to fill any new elements.
445 * This function will %resize the %string to the specified
446 * number of characters. If the number is smaller than the
447 * %string's current size the %string is truncated, otherwise
448 * the %string is extended and new elements are set to @a __c.
451 resize(size_type __n
, _CharT __c
);
454 * @brief Resizes the %string to the specified number of characters.
455 * @param __n Number of characters the %string should contain.
457 * This function will resize the %string to the specified
458 * length. If the new size is smaller than the %string's
459 * current size the %string is truncated, otherwise the %string
460 * is extended and new characters are default-constructed. For
461 * basic types such as char, this means setting them to 0.
464 resize(size_type __n
)
465 { this->resize(__n
, _CharT()); }
467 #if __cplusplus >= 201103L
468 /// A non-binding request to reduce capacity() to size().
470 shrink_to_fit() noexcept
472 if (capacity() > size())
475 { this->reserve(0); }
483 * Returns the total number of characters that the %string can
484 * hold before needing to allocate more memory.
487 capacity() const _GLIBCXX_NOEXCEPT
488 { return this->_M_capacity(); }
491 * @brief Attempt to preallocate enough memory for specified number of
493 * @param __res_arg Number of characters required.
494 * @throw std::length_error If @a __res_arg exceeds @c max_size().
496 * This function attempts to reserve enough memory for the
497 * %string to hold the specified number of characters. If the
498 * number requested is more than max_size(), length_error is
501 * The advantage of this function is that if optimal code is a
502 * necessity and the user can determine the string length that
503 * will be required, the user can reserve the memory in
504 * %advance, and thus prevent a possible reallocation of memory
505 * and copying of %string data.
508 reserve(size_type __res_arg
= 0)
509 { this->_M_reserve(__res_arg
); }
512 * Erases the string, making it empty.
515 clear() _GLIBCXX_NOEXCEPT
516 { this->_M_clear(); }
519 * Returns true if the %string is empty. Equivalent to
520 * <code>*this == ""</code>.
522 _GLIBCXX_NODISCARD
bool
523 empty() const _GLIBCXX_NOEXCEPT
524 { return this->size() == 0; }
528 * @brief Subscript access to the data contained in the %string.
529 * @param __pos The index of the character to access.
530 * @return Read-only (constant) reference to the character.
532 * This operator allows for easy, array-style, data access.
533 * Note that data access with this operator is unchecked and
534 * out_of_range lookups are not defined. (For checked lookups
538 operator[] (size_type __pos
) const _GLIBCXX_NOEXCEPT
540 __glibcxx_assert(__pos
<= this->size());
541 return this->_M_data()[__pos
];
545 * @brief Subscript access to the data contained in the %string.
546 * @param __pos The index of the character to access.
547 * @return Read/write reference to the character.
549 * This operator allows for easy, array-style, data access.
550 * Note that data access with this operator is unchecked and
551 * out_of_range lookups are not defined. (For checked lookups
552 * see at().) Unshares the string.
555 operator[](size_type __pos
) _GLIBCXX_NOEXCEPT
557 // Allow pos == size() both in C++98 mode, as v3 extension,
558 // and in C++11 mode.
559 __glibcxx_assert(__pos
<= this->size());
560 // In pedantic mode be strict in C++98 mode.
561 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus
>= 201103L
562 || __pos
< this->size());
564 return this->_M_data()[__pos
];
568 * @brief Provides access to the data contained in the %string.
569 * @param __n The index of the character to access.
570 * @return Read-only (const) reference to the character.
571 * @throw std::out_of_range If @a __n is an invalid index.
573 * This function provides for safer data access. The parameter
574 * is first checked that it is in the range of the string. The
575 * function throws out_of_range if the check fails.
578 at(size_type __n
) const
580 if (__n
>= this->size())
581 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
582 "(which is %zu) >= this->size() "
585 return this->_M_data()[__n
];
589 * @brief Provides access to the data contained in the %string.
590 * @param __n The index of the character to access.
591 * @return Read/write reference to the character.
592 * @throw std::out_of_range If @a __n is an invalid index.
594 * This function provides for safer data access. The parameter
595 * is first checked that it is in the range of the string. The
596 * function throws out_of_range if the check fails. Success
597 * results in unsharing the string.
602 if (__n
>= this->size())
603 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
604 "(which is %zu) >= this->size() "
608 return this->_M_data()[__n
];
611 #if __cplusplus >= 201103L
613 * Returns a read/write reference to the data at the first
614 * element of the %string.
618 { return operator[](0); }
621 * Returns a read-only (constant) reference to the data at the first
622 * element of the %string.
625 front() const noexcept
626 { return operator[](0); }
629 * Returns a read/write reference to the data at the last
630 * element of the %string.
634 { return operator[](this->size() - 1); }
637 * Returns a read-only (constant) reference to the data at the
638 * last element of the %string.
641 back() const noexcept
642 { return operator[](this->size() - 1); }
647 * @brief Append a string to this string.
648 * @param __str The string to append.
649 * @return Reference to this string.
652 operator+=(const __versa_string
& __str
)
653 { return this->append(__str
); }
656 * @brief Append a C string.
657 * @param __s The C string to append.
658 * @return Reference to this string.
661 operator+=(const _CharT
* __s
)
662 { return this->append(__s
); }
665 * @brief Append a character.
666 * @param __c The character to append.
667 * @return Reference to this string.
670 operator+=(_CharT __c
)
672 this->push_back(__c
);
676 #if __cplusplus >= 201103L
678 * @brief Append an initializer_list of characters.
679 * @param __l The initializer_list of characters to be appended.
680 * @return Reference to this string.
683 operator+=(std::initializer_list
<_CharT
> __l
)
684 { return this->append(__l
.begin(), __l
.end()); }
688 * @brief Append a string to this string.
689 * @param __str The string to append.
690 * @return Reference to this string.
693 append(const __versa_string
& __str
)
694 { return _M_append(__str
._M_data(), __str
.size()); }
697 * @brief Append a substring.
698 * @param __str The string to append.
699 * @param __pos Index of the first character of str to append.
700 * @param __n The number of characters to append.
701 * @return Reference to this string.
702 * @throw std::out_of_range if @a pos is not a valid index.
704 * This function appends @a __n characters from @a __str
705 * starting at @a __pos to this string. If @a __n is is larger
706 * than the number of available characters in @a __str, the
707 * remainder of @a __str is appended.
710 append(const __versa_string
& __str
, size_type __pos
, size_type __n
)
711 { return _M_append(__str
._M_data()
712 + __str
._M_check(__pos
, "__versa_string::append"),
713 __str
._M_limit(__pos
, __n
)); }
716 * @brief Append a C substring.
717 * @param __s The C string to append.
718 * @param __n The number of characters to append.
719 * @return Reference to this string.
722 append(const _CharT
* __s
, size_type __n
)
724 __glibcxx_requires_string_len(__s
, __n
);
725 _M_check_length(size_type(0), __n
, "__versa_string::append");
726 return _M_append(__s
, __n
);
730 * @brief Append a C string.
731 * @param __s The C string to append.
732 * @return Reference to this string.
735 append(const _CharT
* __s
)
737 __glibcxx_requires_string(__s
);
738 const size_type __n
= traits_type::length(__s
);
739 _M_check_length(size_type(0), __n
, "__versa_string::append");
740 return _M_append(__s
, __n
);
744 * @brief Append multiple characters.
745 * @param __n The number of characters to append.
746 * @param __c The character to use.
747 * @return Reference to this string.
749 * Appends n copies of c to this string.
752 append(size_type __n
, _CharT __c
)
753 { return _M_replace_aux(this->size(), size_type(0), __n
, __c
); }
755 #if __cplusplus >= 201103L
757 * @brief Append an initializer_list of characters.
758 * @param __l The initializer_list of characters to append.
759 * @return Reference to this string.
762 append(std::initializer_list
<_CharT
> __l
)
763 { return this->append(__l
.begin(), __l
.end()); }
767 * @brief Append a range of characters.
768 * @param __first Iterator referencing the first character to append.
769 * @param __last Iterator marking the end of the range.
770 * @return Reference to this string.
772 * Appends characters in the range [first,last) to this string.
774 #if __cplusplus >= 201103L
775 template<class _InputIterator
,
776 typename
= std::_RequireInputIter
<_InputIterator
>>
778 template<class _InputIterator
>
781 append(_InputIterator __first
, _InputIterator __last
)
782 { return this->replace(_M_iend(), _M_iend(), __first
, __last
); }
785 * @brief Append a single character.
786 * @param __c Character to append.
789 push_back(_CharT __c
)
791 const size_type __size
= this->size();
792 if (__size
+ 1 > this->capacity() || this->_M_is_shared())
793 this->_M_mutate(__size
, size_type(0), 0, size_type(1));
794 traits_type::assign(this->_M_data()[__size
], __c
);
795 this->_M_set_length(__size
+ 1);
799 * @brief Set value to contents of another string.
800 * @param __str Source string to use.
801 * @return Reference to this string.
804 assign(const __versa_string
& __str
)
806 this->_M_assign(__str
);
810 #if __cplusplus >= 201103L
812 * @brief Set value to contents of another string.
813 * @param __str Source string to use.
814 * @return Reference to this string.
816 * This function sets this string to the exact contents of @a __str.
817 * @a __str is a valid, but unspecified string.
820 assign(__versa_string
&& __str
) noexcept
828 * @brief Set value to a substring of a string.
829 * @param __str The string to use.
830 * @param __pos Index of the first character of str.
831 * @param __n Number of characters to use.
832 * @return Reference to this string.
833 * @throw std::out_of_range if @a __pos is not a valid index.
835 * This function sets this string to the substring of @a __str
836 * consisting of @a __n characters at @a __pos. If @a __n is
837 * is larger than the number of available characters in @a
838 * __str, the remainder of @a __str is used.
841 assign(const __versa_string
& __str
, size_type __pos
, size_type __n
)
842 { return _M_replace(size_type(0), this->size(), __str
._M_data()
843 + __str
._M_check(__pos
, "__versa_string::assign"),
844 __str
._M_limit(__pos
, __n
)); }
847 * @brief Set value to a C substring.
848 * @param __s The C string to use.
849 * @param __n Number of characters to use.
850 * @return Reference to this string.
852 * This function sets the value of this string to the first @a
853 * __n characters of @a __s. If @a __n is is larger than the
854 * number of available characters in @a __s, the remainder of
858 assign(const _CharT
* __s
, size_type __n
)
860 __glibcxx_requires_string_len(__s
, __n
);
861 return _M_replace(size_type(0), this->size(), __s
, __n
);
865 * @brief Set value to contents of a C string.
866 * @param __s The C string to use.
867 * @return Reference to this string.
869 * This function sets the value of this string to the value of
870 * @a __s. The data is copied, so there is no dependence on @a
871 * __s once the function returns.
874 assign(const _CharT
* __s
)
876 __glibcxx_requires_string(__s
);
877 return _M_replace(size_type(0), this->size(), __s
,
878 traits_type::length(__s
));
882 * @brief Set value to multiple characters.
883 * @param __n Length of the resulting string.
884 * @param __c The character to use.
885 * @return Reference to this string.
887 * This function sets the value of this string to @a __n copies of
891 assign(size_type __n
, _CharT __c
)
892 { return _M_replace_aux(size_type(0), this->size(), __n
, __c
); }
895 * @brief Set value to a range of characters.
896 * @param __first Iterator referencing the first character to append.
897 * @param __last Iterator marking the end of the range.
898 * @return Reference to this string.
900 * Sets value of string to characters in the range
903 #if __cplusplus >= 201103L
904 template<class _InputIterator
,
905 typename
= std::_RequireInputIter
<_InputIterator
>>
907 template<class _InputIterator
>
910 assign(_InputIterator __first
, _InputIterator __last
)
911 { return this->replace(_M_ibegin(), _M_iend(), __first
, __last
); }
913 #if __cplusplus >= 201103L
915 * @brief Set value to an initializer_list of characters.
916 * @param __l The initializer_list of characters to assign.
917 * @return Reference to this string.
920 assign(std::initializer_list
<_CharT
> __l
)
921 { return this->assign(__l
.begin(), __l
.end()); }
924 #if __cplusplus >= 201103L
926 * @brief Insert multiple characters.
927 * @param __p Const_iterator referencing location in string to
929 * @param __n Number of characters to insert
930 * @param __c The character to insert.
931 * @return Iterator referencing the first inserted char.
932 * @throw std::length_error If new length exceeds @c max_size().
934 * Inserts @a __n copies of character @a __c starting at the
935 * position referenced by iterator @a __p. If adding
936 * characters causes the length to exceed max_size(),
937 * length_error is thrown. The value of the string doesn't
938 * change if an error is thrown.
941 insert(const_iterator __p
, size_type __n
, _CharT __c
)
943 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
944 const size_type __pos
= __p
- _M_ibegin();
945 this->replace(__p
, __p
, __n
, __c
);
946 return iterator(this->_M_data() + __pos
);
950 * @brief Insert multiple characters.
951 * @param __p Iterator referencing location in string to insert at.
952 * @param __n Number of characters to insert
953 * @param __c The character to insert.
954 * @throw std::length_error If new length exceeds @c max_size().
956 * Inserts @a __n copies of character @a __c starting at the
957 * position referenced by iterator @a __p. If adding
958 * characters causes the length to exceed max_size(),
959 * length_error is thrown. The value of the string doesn't
960 * change if an error is thrown.
963 insert(iterator __p
, size_type __n
, _CharT __c
)
964 { this->replace(__p
, __p
, __n
, __c
); }
967 #if __cplusplus >= 201103L
969 * @brief Insert a range of characters.
970 * @param __p Const_iterator referencing location in string to
972 * @param __beg Start of range.
973 * @param __end End of range.
974 * @return Iterator referencing the first inserted char.
975 * @throw std::length_error If new length exceeds @c max_size().
977 * Inserts characters in range [beg,end). If adding characters
978 * causes the length to exceed max_size(), length_error is
979 * thrown. The value of the string doesn't change if an error
982 template<class _InputIterator
,
983 typename
= std::_RequireInputIter
<_InputIterator
>>
985 insert(const_iterator __p
, _InputIterator __beg
, _InputIterator __end
)
987 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
988 const size_type __pos
= __p
- _M_ibegin();
989 this->replace(__p
, __p
, __beg
, __end
);
990 return iterator(this->_M_data() + __pos
);
994 * @brief Insert a range of characters.
995 * @param __p Iterator referencing location in string to insert at.
996 * @param __beg Start of range.
997 * @param __end End of range.
998 * @throw std::length_error If new length exceeds @c max_size().
1000 * Inserts characters in range [beg,end). If adding characters
1001 * causes the length to exceed max_size(), length_error is
1002 * thrown. The value of the string doesn't change if an error
1005 template<class _InputIterator
>
1007 insert(iterator __p
, _InputIterator __beg
, _InputIterator __end
)
1008 { this->replace(__p
, __p
, __beg
, __end
); }
1011 #if __cplusplus >= 201103L
1013 * @brief Insert an initializer_list of characters.
1014 * @param __p Const_iterator referencing location in string to
1016 * @param __l The initializer_list of characters to insert.
1017 * @return Iterator referencing the first inserted char.
1018 * @throw std::length_error If new length exceeds @c max_size().
1021 insert(const_iterator __p
, std::initializer_list
<_CharT
> __l
)
1022 { return this->insert(__p
, __l
.begin(), __l
.end()); }
1026 * @brief Insert value of a string.
1027 * @param __pos1 Iterator referencing location in string to insert at.
1028 * @param __str The string to insert.
1029 * @return Reference to this string.
1030 * @throw std::length_error If new length exceeds @c max_size().
1032 * Inserts value of @a __str starting at @a __pos1. If adding
1033 * characters causes the length to exceed max_size(),
1034 * length_error is thrown. The value of the string doesn't
1035 * change if an error is thrown.
1038 insert(size_type __pos1
, const __versa_string
& __str
)
1039 { return this->replace(__pos1
, size_type(0),
1040 __str
._M_data(), __str
.size()); }
1043 * @brief Insert a substring.
1044 * @param __pos1 Iterator referencing location in string to insert at.
1045 * @param __str The string to insert.
1046 * @param __pos2 Start of characters in str to insert.
1047 * @param __n Number of characters to insert.
1048 * @return Reference to this string.
1049 * @throw std::length_error If new length exceeds @c max_size().
1050 * @throw std::out_of_range If @a __pos1 > size() or
1051 * @a __pos2 > @a __str.size().
1053 * Starting at @a __pos1, insert @a __n character of @a __str
1054 * beginning with @a __pos2. If adding characters causes the
1055 * length to exceed max_size(), length_error is thrown. If @a
1056 * __pos1 is beyond the end of this string or @a __pos2 is
1057 * beyond the end of @a __str, out_of_range is thrown. The
1058 * value of the string doesn't change if an error is thrown.
1061 insert(size_type __pos1
, const __versa_string
& __str
,
1062 size_type __pos2
, size_type __n
)
1063 { return this->replace(__pos1
, size_type(0), __str
._M_data()
1064 + __str
._M_check(__pos2
, "__versa_string::insert"),
1065 __str
._M_limit(__pos2
, __n
)); }
1068 * @brief Insert a C substring.
1069 * @param __pos Iterator referencing location in string to insert at.
1070 * @param __s The C string to insert.
1071 * @param __n The number of characters to insert.
1072 * @return Reference to this string.
1073 * @throw std::length_error If new length exceeds @c max_size().
1074 * @throw std::out_of_range If @a __pos is beyond the end of this
1077 * Inserts the first @a __n characters of @a __s starting at @a
1078 * __pos. If adding characters causes the length to exceed
1079 * max_size(), length_error is thrown. If @a __pos is beyond
1080 * end(), out_of_range is thrown. The value of the string
1081 * doesn't change if an error is thrown.
1084 insert(size_type __pos
, const _CharT
* __s
, size_type __n
)
1085 { return this->replace(__pos
, size_type(0), __s
, __n
); }
1088 * @brief Insert a C string.
1089 * @param __pos Iterator referencing location in string to insert at.
1090 * @param __s The C string to insert.
1091 * @return Reference to this string.
1092 * @throw std::length_error If new length exceeds @c max_size().
1093 * @throw std::out_of_range If @a __pos is beyond the end of this
1096 * Inserts the first @a __n characters of @a __s starting at @a
1097 * __pos. If adding characters causes the length to exceed
1098 * max_size(), length_error is thrown. If @a __pos is beyond
1099 * end(), out_of_range is thrown. The value of the string
1100 * doesn't change if an error is thrown.
1103 insert(size_type __pos
, const _CharT
* __s
)
1105 __glibcxx_requires_string(__s
);
1106 return this->replace(__pos
, size_type(0), __s
,
1107 traits_type::length(__s
));
1111 * @brief Insert multiple characters.
1112 * @param __pos Index in string to insert at.
1113 * @param __n Number of characters to insert
1114 * @param __c The character to insert.
1115 * @return Reference to this string.
1116 * @throw std::length_error If new length exceeds @c max_size().
1117 * @throw std::out_of_range If @a __pos is beyond the end of this
1120 * Inserts @a __n copies of character @a __c starting at index
1121 * @a __pos. If adding characters causes the length to exceed
1122 * max_size(), length_error is thrown. If @a __pos > length(),
1123 * out_of_range is thrown. The value of the string doesn't
1124 * change if an error is thrown.
1127 insert(size_type __pos
, size_type __n
, _CharT __c
)
1128 { return _M_replace_aux(_M_check(__pos
, "__versa_string::insert"),
1129 size_type(0), __n
, __c
); }
1132 * @brief Insert one character.
1133 * @param __p Iterator referencing position in string to insert at.
1134 * @param __c The character to insert.
1135 * @return Iterator referencing newly inserted char.
1136 * @throw std::length_error If new length exceeds @c max_size().
1138 * Inserts character @a __c at position referenced by @a __p.
1139 * If adding character causes the length to exceed max_size(),
1140 * length_error is thrown. If @a __p is beyond end of string,
1141 * out_of_range is thrown. The value of the string doesn't
1142 * change if an error is thrown.
1145 #if __cplusplus >= 201103L
1146 insert(const_iterator __p
, _CharT __c
)
1148 insert(iterator __p
, _CharT __c
)
1151 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
1152 const size_type __pos
= __p
- _M_ibegin();
1153 _M_replace_aux(__pos
, size_type(0), size_type(1), __c
);
1154 this->_M_set_leaked();
1155 return iterator(this->_M_data() + __pos
);
1159 * @brief Remove characters.
1160 * @param __pos Index of first character to remove (default 0).
1161 * @param __n Number of characters to remove (default remainder).
1162 * @return Reference to this string.
1163 * @throw std::out_of_range If @a __pos is beyond the end of this
1166 * Removes @a __n characters from this string starting at @a
1167 * __pos. The length of the string is reduced by @a __n. If
1168 * there are < @a __n characters to remove, the remainder of
1169 * the string is truncated. If @a __p is beyond end of string,
1170 * out_of_range is thrown. The value of the string doesn't
1171 * change if an error is thrown.
1174 erase(size_type __pos
= 0, size_type __n
= npos
)
1176 this->_M_erase(_M_check(__pos
, "__versa_string::erase"),
1177 _M_limit(__pos
, __n
));
1182 * @brief Remove one character.
1183 * @param __position Iterator referencing the character to remove.
1184 * @return iterator referencing same location after removal.
1186 * Removes the character at @a __position from this string. The
1187 * value of the string doesn't change if an error is thrown.
1190 #if __cplusplus >= 201103L
1191 erase(const_iterator __position
)
1193 erase(iterator __position
)
1196 _GLIBCXX_DEBUG_PEDASSERT(__position
>= _M_ibegin()
1197 && __position
< _M_iend());
1198 const size_type __pos
= __position
- _M_ibegin();
1199 this->_M_erase(__pos
, size_type(1));
1200 this->_M_set_leaked();
1201 return iterator(this->_M_data() + __pos
);
1205 * @brief Remove a range of characters.
1206 * @param __first Iterator referencing the first character to remove.
1207 * @param __last Iterator referencing the end of the range.
1208 * @return Iterator referencing location of first after removal.
1210 * Removes the characters in the range [first,last) from this
1211 * string. The value of the string doesn't change if an error
1215 #if __cplusplus >= 201103L
1216 erase(const_iterator __first
, const_iterator __last
)
1218 erase(iterator __first
, iterator __last
)
1221 _GLIBCXX_DEBUG_PEDASSERT(__first
>= _M_ibegin() && __first
<= __last
1222 && __last
<= _M_iend());
1223 const size_type __pos
= __first
- _M_ibegin();
1224 this->_M_erase(__pos
, __last
- __first
);
1225 this->_M_set_leaked();
1226 return iterator(this->_M_data() + __pos
);
1229 #if __cplusplus >= 201103L
1231 * @brief Remove the last character.
1233 * The string must be non-empty.
1237 { this->_M_erase(size()-1, 1); }
1241 * @brief Replace characters with value from another string.
1242 * @param __pos Index of first character to replace.
1243 * @param __n Number of characters to be replaced.
1244 * @param __str String to insert.
1245 * @return Reference to this string.
1246 * @throw std::out_of_range If @a __pos is beyond the end of this
1248 * @throw std::length_error If new length exceeds @c max_size().
1250 * Removes the characters in the range [pos,pos+n) from this
1251 * string. In place, the value of @a __str is inserted. If @a
1252 * __pos is beyond end of string, out_of_range is thrown. If
1253 * the length of the result exceeds max_size(), length_error is
1254 * thrown. The value of the string doesn't change if an error
1258 replace(size_type __pos
, size_type __n
, const __versa_string
& __str
)
1259 { return this->replace(__pos
, __n
, __str
._M_data(), __str
.size()); }
1262 * @brief Replace characters with value from another string.
1263 * @param __pos1 Index of first character to replace.
1264 * @param __n1 Number of characters to be replaced.
1265 * @param __str String to insert.
1266 * @param __pos2 Index of first character of str to use.
1267 * @param __n2 Number of characters from str to use.
1268 * @return Reference to this string.
1269 * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 >
1271 * @throw std::length_error If new length exceeds @c max_size().
1273 * Removes the characters in the range [pos1,pos1 + n) from
1274 * this string. In place, the value of @a __str is inserted.
1275 * If @a __pos is beyond end of string, out_of_range is thrown.
1276 * If the length of the result exceeds max_size(), length_error
1277 * is thrown. The value of the string doesn't change if an
1281 replace(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
1282 size_type __pos2
, size_type __n2
)
1284 return this->replace(__pos1
, __n1
, __str
._M_data()
1285 + __str
._M_check(__pos2
,
1286 "__versa_string::replace"),
1287 __str
._M_limit(__pos2
, __n2
));
1291 * @brief Replace characters with value of a C substring.
1292 * @param __pos Index of first character to replace.
1293 * @param __n1 Number of characters to be replaced.
1294 * @param __s C string to insert.
1295 * @param __n2 Number of characters from @a __s to use.
1296 * @return Reference to this string.
1297 * @throw std::out_of_range If @a __pos1 > size().
1298 * @throw std::length_error If new length exceeds @c max_size().
1300 * Removes the characters in the range [pos,pos + n1) from this
1301 * string. In place, the first @a __n2 characters of @a __s
1302 * are inserted, or all of @a __s if @a __n2 is too large. If
1303 * @a __pos is beyond end of string, out_of_range is thrown.
1304 * If the length of result exceeds max_size(), length_error is
1305 * thrown. The value of the string doesn't change if an error
1309 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
,
1312 __glibcxx_requires_string_len(__s
, __n2
);
1313 return _M_replace(_M_check(__pos
, "__versa_string::replace"),
1314 _M_limit(__pos
, __n1
), __s
, __n2
);
1318 * @brief Replace characters with value of a C string.
1319 * @param __pos Index of first character to replace.
1320 * @param __n1 Number of characters to be replaced.
1321 * @param __s C string to insert.
1322 * @return Reference to this string.
1323 * @throw std::out_of_range If @a __pos > size().
1324 * @throw std::length_error If new length exceeds @c max_size().
1326 * Removes the characters in the range [pos,pos + n1) from this
1327 * string. In place, the characters of @a __s are inserted. If
1328 * @a pos is beyond end of string, out_of_range is thrown. If
1329 * the length of result exceeds max_size(), length_error is thrown.
1330 * The value of the string doesn't change if an error is thrown.
1333 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
)
1335 __glibcxx_requires_string(__s
);
1336 return this->replace(__pos
, __n1
, __s
, traits_type::length(__s
));
1340 * @brief Replace characters with multiple characters.
1341 * @param __pos Index of first character to replace.
1342 * @param __n1 Number of characters to be replaced.
1343 * @param __n2 Number of characters to insert.
1344 * @param __c Character to insert.
1345 * @return Reference to this string.
1346 * @throw std::out_of_range If @a __pos > size().
1347 * @throw std::length_error If new length exceeds @c max_size().
1349 * Removes the characters in the range [pos,pos + n1) from this
1350 * string. In place, @a __n2 copies of @a __c are inserted.
1351 * If @a __pos is beyond end of string, out_of_range is thrown.
1352 * If the length of result exceeds max_size(), length_error is
1353 * thrown. The value of the string doesn't change if an error
1357 replace(size_type __pos
, size_type __n1
, size_type __n2
, _CharT __c
)
1358 { return _M_replace_aux(_M_check(__pos
, "__versa_string::replace"),
1359 _M_limit(__pos
, __n1
), __n2
, __c
); }
1362 * @brief Replace range of characters with string.
1363 * @param __i1 Iterator referencing start of range to replace.
1364 * @param __i2 Iterator referencing end of range to replace.
1365 * @param __str String value to insert.
1366 * @return Reference to this string.
1367 * @throw std::length_error If new length exceeds @c max_size().
1369 * Removes the characters in the range [i1,i2). In place, the
1370 * value of @a __str is inserted. If the length of result
1371 * exceeds max_size(), length_error is thrown. The value of
1372 * the string doesn't change if an error is thrown.
1375 #if __cplusplus >= 201103L
1376 replace(const_iterator __i1
, const_iterator __i2
,
1377 const __versa_string
& __str
)
1379 replace(iterator __i1
, iterator __i2
, const __versa_string
& __str
)
1381 { return this->replace(__i1
, __i2
, __str
._M_data(), __str
.size()); }
1384 * @brief Replace range of characters with C substring.
1385 * @param __i1 Iterator referencing start of range to replace.
1386 * @param __i2 Iterator referencing end of range to replace.
1387 * @param __s C string value to insert.
1388 * @param __n Number of characters from s to insert.
1389 * @return Reference to this string.
1390 * @throw std::length_error If new length exceeds @c max_size().
1392 * Removes the characters in the range [i1,i2). In place, the
1393 * first @a n characters of @a __s are inserted. If the length
1394 * of result exceeds max_size(), length_error is thrown. The
1395 * value of the string doesn't change if an error is thrown.
1398 #if __cplusplus >= 201103L
1399 replace(const_iterator __i1
, const_iterator __i2
,
1400 const _CharT
* __s
, size_type __n
)
1402 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
, size_type __n
)
1405 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1406 && __i2
<= _M_iend());
1407 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
, __s
, __n
);
1411 * @brief Replace range of characters with C string.
1412 * @param __i1 Iterator referencing start of range to replace.
1413 * @param __i2 Iterator referencing end of range to replace.
1414 * @param __s C string value to insert.
1415 * @return Reference to this string.
1416 * @throw std::length_error If new length exceeds @c max_size().
1418 * Removes the characters in the range [i1,i2). In place, the
1419 * characters of @a __s are inserted. If the length of result
1420 * exceeds max_size(), length_error is thrown. The value of
1421 * the string doesn't change if an error is thrown.
1424 #if __cplusplus >= 201103L
1425 replace(const_iterator __i1
, const_iterator __i2
, const _CharT
* __s
)
1427 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
)
1430 __glibcxx_requires_string(__s
);
1431 return this->replace(__i1
, __i2
, __s
, traits_type::length(__s
));
1435 * @brief Replace range of characters with multiple characters
1436 * @param __i1 Iterator referencing start of range to replace.
1437 * @param __i2 Iterator referencing end of range to replace.
1438 * @param __n Number of characters to insert.
1439 * @param __c Character to insert.
1440 * @return Reference to this string.
1441 * @throw std::length_error If new length exceeds @c max_size().
1443 * Removes the characters in the range [i1,i2). In place, @a
1444 * __n copies of @a __c are inserted. If the length of result
1445 * exceeds max_size(), length_error is thrown. The value of
1446 * the string doesn't change if an error is thrown.
1449 #if __cplusplus >= 201103L
1450 replace(const_iterator __i1
, const_iterator __i2
, size_type __n
,
1453 replace(iterator __i1
, iterator __i2
, size_type __n
, _CharT __c
)
1456 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1457 && __i2
<= _M_iend());
1458 return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __c
);
1462 * @brief Replace range of characters with range.
1463 * @param __i1 Iterator referencing start of range to replace.
1464 * @param __i2 Iterator referencing end of range to replace.
1465 * @param __k1 Iterator referencing start of range to insert.
1466 * @param __k2 Iterator referencing end of range to insert.
1467 * @return Reference to this string.
1468 * @throw std::length_error If new length exceeds @c max_size().
1470 * Removes the characters in the range [i1,i2). In place,
1471 * characters in the range [k1,k2) are inserted. If the length
1472 * of result exceeds max_size(), length_error is thrown. The
1473 * value of the string doesn't change if an error is thrown.
1475 #if __cplusplus >= 201103L
1476 template<class _InputIterator
,
1477 typename
= std::_RequireInputIter
<_InputIterator
>>
1479 replace(const_iterator __i1
, const_iterator __i2
,
1480 _InputIterator __k1
, _InputIterator __k2
)
1482 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1483 && __i2
<= _M_iend());
1484 __glibcxx_requires_valid_range(__k1
, __k2
);
1485 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
,
1486 std::__false_type());
1489 template<class _InputIterator
>
1491 replace(iterator __i1
, iterator __i2
,
1492 _InputIterator __k1
, _InputIterator __k2
)
1494 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1495 && __i2
<= _M_iend());
1496 __glibcxx_requires_valid_range(__k1
, __k2
);
1497 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
1498 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
, _Integral());
1502 // Specializations for the common case of pointer and iterator:
1503 // useful to avoid the overhead of temporary buffering in _M_replace.
1505 #if __cplusplus >= 201103L
1506 replace(const_iterator __i1
, const_iterator __i2
,
1507 _CharT
* __k1
, _CharT
* __k2
)
1509 replace(iterator __i1
, iterator __i2
,
1510 _CharT
* __k1
, _CharT
* __k2
)
1513 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1514 && __i2
<= _M_iend());
1515 __glibcxx_requires_valid_range(__k1
, __k2
);
1516 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1521 #if __cplusplus >= 201103L
1522 replace(const_iterator __i1
, const_iterator __i2
,
1523 const _CharT
* __k1
, const _CharT
* __k2
)
1525 replace(iterator __i1
, iterator __i2
,
1526 const _CharT
* __k1
, const _CharT
* __k2
)
1529 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1530 && __i2
<= _M_iend());
1531 __glibcxx_requires_valid_range(__k1
, __k2
);
1532 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1537 #if __cplusplus >= 201103L
1538 replace(const_iterator __i1
, const_iterator __i2
,
1539 iterator __k1
, iterator __k2
)
1541 replace(iterator __i1
, iterator __i2
,
1542 iterator __k1
, iterator __k2
)
1545 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1546 && __i2
<= _M_iend());
1547 __glibcxx_requires_valid_range(__k1
, __k2
);
1548 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1549 __k1
.base(), __k2
- __k1
);
1553 #if __cplusplus >= 201103L
1554 replace(const_iterator __i1
, const_iterator __i2
,
1555 const_iterator __k1
, const_iterator __k2
)
1557 replace(iterator __i1
, iterator __i2
,
1558 const_iterator __k1
, const_iterator __k2
)
1561 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1562 && __i2
<= _M_iend());
1563 __glibcxx_requires_valid_range(__k1
, __k2
);
1564 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1565 __k1
.base(), __k2
- __k1
);
1568 #if __cplusplus >= 201103L
1570 * @brief Replace range of characters with initializer_list.
1571 * @param __i1 Iterator referencing start of range to replace.
1572 * @param __i2 Iterator referencing end of range to replace.
1573 * @param __l The initializer_list of characters to insert.
1574 * @return Reference to this string.
1575 * @throw std::length_error If new length exceeds @c max_size().
1577 * Removes the characters in the range [i1,i2). In place,
1578 * characters in the range [k1,k2) are inserted. If the length
1579 * of result exceeds max_size(), length_error is thrown. The
1580 * value of the string doesn't change if an error is thrown.
1583 replace(const_iterator __i1
, const_iterator __i2
,
1584 std::initializer_list
<_CharT
> __l
)
1585 { return this->replace(__i1
, __i2
, __l
.begin(), __l
.end()); }
1589 template<class _Integer
>
1591 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1592 _Integer __n
, _Integer __val
, std::__true_type
)
1593 { return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __val
); }
1595 template<class _InputIterator
>
1597 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1598 _InputIterator __k1
, _InputIterator __k2
,
1602 _M_replace_aux(size_type __pos1
, size_type __n1
, size_type __n2
,
1606 _M_replace(size_type __pos
, size_type __len1
, const _CharT
* __s
,
1607 const size_type __len2
);
1610 _M_append(const _CharT
* __s
, size_type __n
);
1615 * @brief Copy substring into C string.
1616 * @param __s C string to copy value into.
1617 * @param __n Number of characters to copy.
1618 * @param __pos Index of first character to copy.
1619 * @return Number of characters actually copied
1620 * @throw std::out_of_range If pos > size().
1622 * Copies up to @a __n characters starting at @a __pos into the
1623 * C string @a s. If @a __pos is greater than size(),
1624 * out_of_range is thrown.
1627 copy(_CharT
* __s
, size_type __n
, size_type __pos
= 0) const;
1630 * @brief Swap contents with another string.
1631 * @param __s String to swap with.
1633 * Exchanges the contents of this string with that of @a __s in
1637 swap(__versa_string
& __s
) _GLIBCXX_NOEXCEPT
1638 { this->_M_swap(__s
); }
1640 // String operations:
1642 * @brief Return const pointer to null-terminated contents.
1644 * This is a handle to internal data. Do not modify or dire things may
1648 c_str() const _GLIBCXX_NOEXCEPT
1649 { return this->_M_data(); }
1652 * @brief Return const pointer to contents.
1654 * This is a handle to internal data. Do not modify or dire things may
1658 data() const _GLIBCXX_NOEXCEPT
1659 { return this->_M_data(); }
1662 * @brief Return copy of allocator used to construct this string.
1665 get_allocator() const _GLIBCXX_NOEXCEPT
1666 { return allocator_type(this->_M_get_allocator()); }
1669 * @brief Find position of a C substring.
1670 * @param __s C string to locate.
1671 * @param __pos Index of character to search from.
1672 * @param __n Number of characters from @a __s to search for.
1673 * @return Index of start of first occurrence.
1675 * Starting from @a __pos, searches forward for the first @a
1676 * __n characters in @a __s within this string. If found,
1677 * returns the index where it begins. If not found, returns
1681 find(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1684 * @brief Find position of a string.
1685 * @param __str String to locate.
1686 * @param __pos Index of character to search from (default 0).
1687 * @return Index of start of first occurrence.
1689 * Starting from @a __pos, searches forward for value of @a
1690 * __str within this string. If found, returns the index where
1691 * it begins. If not found, returns npos.
1694 find(const __versa_string
& __str
, size_type __pos
= 0) const
1696 { return this->find(__str
.data(), __pos
, __str
.size()); }
1699 * @brief Find position of a C string.
1700 * @param __s C string to locate.
1701 * @param __pos Index of character to search from (default 0).
1702 * @return Index of start of first occurrence.
1704 * Starting from @a __pos, searches forward for the value of @a
1705 * __s within this string. If found, returns the index where
1706 * it begins. If not found, returns npos.
1709 find(const _CharT
* __s
, size_type __pos
= 0) const
1711 __glibcxx_requires_string(__s
);
1712 return this->find(__s
, __pos
, traits_type::length(__s
));
1716 * @brief Find position of a character.
1717 * @param __c Character to locate.
1718 * @param __pos Index of character to search from (default 0).
1719 * @return Index of first occurrence.
1721 * Starting from @a __pos, searches forward for @a __c within
1722 * this string. If found, returns the index where it was
1723 * found. If not found, returns npos.
1726 find(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
;
1729 * @brief Find last position of a string.
1730 * @param __str String to locate.
1731 * @param __pos Index of character to search back from (default end).
1732 * @return Index of start of last occurrence.
1734 * Starting from @a __pos, searches backward for value of @a
1735 * __str within this string. If found, returns the index where
1736 * it begins. If not found, returns npos.
1739 rfind(const __versa_string
& __str
, size_type __pos
= npos
) const
1741 { return this->rfind(__str
.data(), __pos
, __str
.size()); }
1744 * @brief Find last position of a C substring.
1745 * @param __s C string to locate.
1746 * @param __pos Index of character to search back from.
1747 * @param __n Number of characters from s to search for.
1748 * @return Index of start of last occurrence.
1750 * Starting from @a __pos, searches backward for the first @a
1751 * __n characters in @a __s within this string. If found,
1752 * returns the index where it begins. If not found, returns
1756 rfind(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1759 * @brief Find last position of a C string.
1760 * @param __s C string to locate.
1761 * @param __pos Index of character to start search at (default end).
1762 * @return Index of start of last occurrence.
1764 * Starting from @a __pos, searches backward for the value of
1765 * @a __s within this string. If found, returns the index
1766 * where it begins. If not found, returns npos.
1769 rfind(const _CharT
* __s
, size_type __pos
= npos
) const
1771 __glibcxx_requires_string(__s
);
1772 return this->rfind(__s
, __pos
, traits_type::length(__s
));
1776 * @brief Find last position of a character.
1777 * @param __c Character to locate.
1778 * @param __pos Index of character to search back from (default end).
1779 * @return Index of last occurrence.
1781 * Starting from @a __pos, searches backward for @a __c within
1782 * this string. If found, returns the index where it was
1783 * found. If not found, returns npos.
1786 rfind(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
;
1789 * @brief Find position of a character of string.
1790 * @param __str String containing characters to locate.
1791 * @param __pos Index of character to search from (default 0).
1792 * @return Index of first occurrence.
1794 * Starting from @a __pos, searches forward for one of the characters of
1795 * @a __str within this string. If found, returns the index where it was
1796 * found. If not found, returns npos.
1799 find_first_of(const __versa_string
& __str
, size_type __pos
= 0) const
1801 { return this->find_first_of(__str
.data(), __pos
, __str
.size()); }
1804 * @brief Find position of a character of C substring.
1805 * @param __s String containing characters to locate.
1806 * @param __pos Index of character to search from.
1807 * @param __n Number of characters from s to search for.
1808 * @return Index of first occurrence.
1810 * Starting from @a __pos, searches forward for one of the
1811 * first @a __n characters of @a __s within this string. If
1812 * found, returns the index where it was found. If not found,
1816 find_first_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1819 * @brief Find position of a character of C string.
1820 * @param __s String containing characters to locate.
1821 * @param __pos Index of character to search from (default 0).
1822 * @return Index of first occurrence.
1824 * Starting from @a __pos, searches forward for one of the
1825 * characters of @a __s within this string. If found, returns
1826 * the index where it was found. If not found, returns npos.
1829 find_first_of(const _CharT
* __s
, size_type __pos
= 0) const
1831 __glibcxx_requires_string(__s
);
1832 return this->find_first_of(__s
, __pos
, traits_type::length(__s
));
1836 * @brief Find position of a character.
1837 * @param __c Character to locate.
1838 * @param __pos Index of character to search from (default 0).
1839 * @return Index of first occurrence.
1841 * Starting from @a __pos, searches forward for the character
1842 * @a __c within this string. If found, returns the index
1843 * where it was found. If not found, returns npos.
1845 * Note: equivalent to find(c, pos).
1848 find_first_of(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
1849 { return this->find(__c
, __pos
); }
1852 * @brief Find last position of a character of string.
1853 * @param __str String containing characters to locate.
1854 * @param __pos Index of character to search back from (default end).
1855 * @return Index of last occurrence.
1857 * Starting from @a __pos, searches backward for one of the
1858 * characters of @a __str within this string. If found,
1859 * returns the index where it was found. If not found, returns
1863 find_last_of(const __versa_string
& __str
, size_type __pos
= npos
) const
1865 { return this->find_last_of(__str
.data(), __pos
, __str
.size()); }
1868 * @brief Find last position of a character of C substring.
1869 * @param __s C string containing characters to locate.
1870 * @param __pos Index of character to search back from.
1871 * @param __n Number of characters from s to search for.
1872 * @return Index of last occurrence.
1874 * Starting from @a __pos, searches backward for one of the
1875 * first @a __n characters of @a __s within this string. If
1876 * found, returns the index where it was found. If not found,
1880 find_last_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1883 * @brief Find last position of a character of C string.
1884 * @param __s C string containing characters to locate.
1885 * @param __pos Index of character to search back from (default end).
1886 * @return Index of last occurrence.
1888 * Starting from @a __pos, searches backward for one of the
1889 * characters of @a __s within this string. If found, returns
1890 * the index where it was found. If not found, returns npos.
1893 find_last_of(const _CharT
* __s
, size_type __pos
= npos
) const
1895 __glibcxx_requires_string(__s
);
1896 return this->find_last_of(__s
, __pos
, traits_type::length(__s
));
1900 * @brief Find last position of a character.
1901 * @param __c Character to locate.
1902 * @param __pos Index of character to search back from (default end).
1903 * @return Index of last occurrence.
1905 * Starting from @a __pos, searches backward for @a __c within
1906 * this string. If found, returns the index where it was
1907 * found. If not found, returns npos.
1909 * Note: equivalent to rfind(c, pos).
1912 find_last_of(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1913 { return this->rfind(__c
, __pos
); }
1916 * @brief Find position of a character not in string.
1917 * @param __str String containing characters to avoid.
1918 * @param __pos Index of character to search from (default 0).
1919 * @return Index of first occurrence.
1921 * Starting from @a __pos, searches forward for a character not
1922 * contained in @a __str within this string. If found, returns
1923 * the index where it was found. If not found, returns npos.
1926 find_first_not_of(const __versa_string
& __str
, size_type __pos
= 0) const
1928 { return this->find_first_not_of(__str
.data(), __pos
, __str
.size()); }
1931 * @brief Find position of a character not in C substring.
1932 * @param __s C string containing characters to avoid.
1933 * @param __pos Index of character to search from.
1934 * @param __n Number of characters from s to consider.
1935 * @return Index of first occurrence.
1937 * Starting from @a __pos, searches forward for a character not
1938 * contained in the first @a __n characters of @a __s within
1939 * this string. If found, returns the index where it was
1940 * found. If not found, returns npos.
1943 find_first_not_of(const _CharT
* __s
, size_type __pos
,
1944 size_type __n
) const;
1947 * @brief Find position of a character not in C string.
1948 * @param __s C string containing characters to avoid.
1949 * @param __pos Index of character to search from (default 0).
1950 * @return Index of first occurrence.
1952 * Starting from @a __pos, searches forward for a character not
1953 * contained in @a __s within this string. If found, returns
1954 * the index where it was found. If not found, returns npos.
1957 find_first_not_of(const _CharT
* __s
, size_type __pos
= 0) const
1959 __glibcxx_requires_string(__s
);
1960 return this->find_first_not_of(__s
, __pos
, traits_type::length(__s
));
1964 * @brief Find position of a different character.
1965 * @param __c Character to avoid.
1966 * @param __pos Index of character to search from (default 0).
1967 * @return Index of first occurrence.
1969 * Starting from @a __pos, searches forward for a character
1970 * other than @a __c within this string. If found, returns the
1971 * index where it was found. If not found, returns npos.
1974 find_first_not_of(_CharT __c
, size_type __pos
= 0) const
1978 * @brief Find last position of a character not in string.
1979 * @param __str String containing characters to avoid.
1980 * @param __pos Index of character to search back from (default end).
1981 * @return Index of last occurrence.
1983 * Starting from @a __pos, searches backward for a character
1984 * not contained in @a __str within this string. If found,
1985 * returns the index where it was found. If not found, returns
1989 find_last_not_of(const __versa_string
& __str
,
1990 size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1991 { return this->find_last_not_of(__str
.data(), __pos
, __str
.size()); }
1994 * @brief Find last position of a character not in C substring.
1995 * @param __s C string containing characters to avoid.
1996 * @param __pos Index of character to search back from.
1997 * @param __n Number of characters from s to consider.
1998 * @return Index of last occurrence.
2000 * Starting from @a __pos, searches backward for a character
2001 * not contained in the first @a __n characters of @a __s
2002 * within this string. If found, returns the index where it
2003 * was found. If not found, returns npos.
2006 find_last_not_of(const _CharT
* __s
, size_type __pos
,
2007 size_type __n
) const;
2009 * @brief Find last position of a character not in C string.
2010 * @param __s C string containing characters to avoid.
2011 * @param __pos Index of character to search back from (default end).
2012 * @return Index of last occurrence.
2014 * Starting from @a __pos, searches backward for a character
2015 * not contained in @a __s within this string. If found,
2016 * returns the index where it was found. If not found, returns
2020 find_last_not_of(const _CharT
* __s
, size_type __pos
= npos
) const
2022 __glibcxx_requires_string(__s
);
2023 return this->find_last_not_of(__s
, __pos
, traits_type::length(__s
));
2027 * @brief Find last position of a different character.
2028 * @param __c Character to avoid.
2029 * @param __pos Index of character to search back from (default end).
2030 * @return Index of last occurrence.
2032 * Starting from @a __pos, searches backward for a character
2033 * other than @a __c within this string. If found, returns the
2034 * index where it was found. If not found, returns npos.
2037 find_last_not_of(_CharT __c
, size_type __pos
= npos
) const
2041 * @brief Get a substring.
2042 * @param __pos Index of first character (default 0).
2043 * @param __n Number of characters in substring (default remainder).
2044 * @return The new string.
2045 * @throw std::out_of_range If pos > size().
2047 * Construct and return a new string using the @a __n
2048 * characters starting at @a __pos. If the string is too
2049 * short, use the remainder of the characters. If @a __pos is
2050 * beyond the end of the string, out_of_range is thrown.
2053 substr(size_type __pos
= 0, size_type __n
= npos
) const
2055 return __versa_string(*this, _M_check(__pos
, "__versa_string::substr"),
2060 * @brief Compare to a string.
2061 * @param __str String to compare against.
2062 * @return Integer < 0, 0, or > 0.
2064 * Returns an integer < 0 if this string is ordered before @a
2065 * __str, 0 if their values are equivalent, or > 0 if this
2066 * string is ordered after @a __str. Determines the effective
2067 * length rlen of the strings to compare as the smallest of
2068 * size() and str.size(). The function then compares the two
2069 * strings by calling traits::compare(data(), str.data(),rlen).
2070 * If the result of the comparison is nonzero returns it,
2071 * otherwise the shorter one is ordered first.
2074 compare(const __versa_string
& __str
) const
2076 if (this->_M_compare(__str
))
2079 const size_type __size
= this->size();
2080 const size_type __osize
= __str
.size();
2081 const size_type __len
= std::min(__size
, __osize
);
2083 int __r
= traits_type::compare(this->_M_data(), __str
.data(), __len
);
2085 __r
= this->_S_compare(__size
, __osize
);
2090 * @brief Compare substring to a string.
2091 * @param __pos Index of first character of substring.
2092 * @param __n Number of characters in substring.
2093 * @param __str String to compare against.
2094 * @return Integer < 0, 0, or > 0.
2096 * Form the substring of this string from the @a __n characters
2097 * starting at @a __pos. Returns an integer < 0 if the
2098 * substring is ordered before @a __str, 0 if their values are
2099 * equivalent, or > 0 if the substring is ordered after @a
2100 * __str. Determines the effective length rlen of the strings
2101 * to compare as the smallest of the length of the substring
2102 * and @a __str.size(). The function then compares the two
2103 * strings by calling
2104 * traits::compare(substring.data(),str.data(),rlen). If the
2105 * result of the comparison is nonzero returns it, otherwise
2106 * the shorter one is ordered first.
2109 compare(size_type __pos
, size_type __n
,
2110 const __versa_string
& __str
) const;
2113 * @brief Compare substring to a substring.
2114 * @param __pos1 Index of first character of substring.
2115 * @param __n1 Number of characters in substring.
2116 * @param __str String to compare against.
2117 * @param __pos2 Index of first character of substring of str.
2118 * @param __n2 Number of characters in substring of str.
2119 * @return Integer < 0, 0, or > 0.
2121 * Form the substring of this string from the @a __n1
2122 * characters starting at @a __pos1. Form the substring of @a
2123 * __str from the @a __n2 characters starting at @a __pos2.
2124 * Returns an integer < 0 if this substring is ordered before
2125 * the substring of @a __str, 0 if their values are equivalent,
2126 * or > 0 if this substring is ordered after the substring of
2127 * @a __str. Determines the effective length rlen of the
2128 * strings to compare as the smallest of the lengths of the
2129 * substrings. The function then compares the two strings by
2131 * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
2132 * If the result of the comparison is nonzero returns it,
2133 * otherwise the shorter one is ordered first.
2136 compare(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
2137 size_type __pos2
, size_type __n2
) const;
2140 * @brief Compare to a C string.
2141 * @param __s C string to compare against.
2142 * @return Integer < 0, 0, or > 0.
2144 * Returns an integer < 0 if this string is ordered before @a
2145 * __s, 0 if their values are equivalent, or > 0 if this string
2146 * is ordered after @a __s. Determines the effective length
2147 * rlen of the strings to compare as the smallest of size() and
2148 * the length of a string constructed from @a __s. The
2149 * function then compares the two strings by calling
2150 * traits::compare(data(),s,rlen). If the result of the
2151 * comparison is nonzero returns it, otherwise the shorter one
2155 compare(const _CharT
* __s
) const;
2157 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2158 // 5 String::compare specification questionable
2160 * @brief Compare substring to a C string.
2161 * @param __pos Index of first character of substring.
2162 * @param __n1 Number of characters in substring.
2163 * @param __s C string to compare against.
2164 * @return Integer < 0, 0, or > 0.
2166 * Form the substring of this string from the @a __n1
2167 * characters starting at @a __pos. Returns an integer < 0 if
2168 * the substring is ordered before @a __s, 0 if their values
2169 * are equivalent, or > 0 if the substring is ordered after @a
2170 * __s. Determines the effective length rlen of the strings to
2171 * compare as the smallest of the length of the substring and
2172 * the length of a string constructed from @a __s. The
2173 * function then compares the two string by calling
2174 * traits::compare(substring.data(),s,rlen). If the result of
2175 * the comparison is nonzero returns it, otherwise the shorter
2176 * one is ordered first.
2179 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
) const;
2182 * @brief Compare substring against a character array.
2183 * @param __pos Index of first character of substring.
2184 * @param __n1 Number of characters in substring.
2185 * @param __s character array to compare against.
2186 * @param __n2 Number of characters of s.
2187 * @return Integer < 0, 0, or > 0.
2189 * Form the substring of this string from the @a __n1
2190 * characters starting at @a __pos. Form a string from the
2191 * first @a __n2 characters of @a __s. Returns an integer < 0
2192 * if this substring is ordered before the string from @a __s,
2193 * 0 if their values are equivalent, or > 0 if this substring
2194 * is ordered after the string from @a __s. Determines the
2195 * effective length rlen of the strings to compare as the
2196 * smallest of the length of the substring and @a __n2. The
2197 * function then compares the two strings by calling
2198 * traits::compare(substring.data(),__s,rlen). If the result of
2199 * the comparison is nonzero returns it, otherwise the shorter
2200 * one is ordered first.
2202 * NB: __s must have at least n2 characters, <em>\\0</em> has no special
2206 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
,
2207 size_type __n2
) const;
2212 * @brief Concatenate two strings.
2213 * @param __lhs First string.
2214 * @param __rhs Last string.
2215 * @return New string with value of @a __lhs followed by @a __rhs.
2217 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2218 template <typename
, typename
, typename
> class _Base
>
2219 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2220 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2221 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2224 * @brief Concatenate C string and string.
2225 * @param __lhs First string.
2226 * @param __rhs Last string.
2227 * @return New string with value of @a __lhs followed by @a __rhs.
2229 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2230 template <typename
, typename
, typename
> class _Base
>
2231 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2232 operator+(const _CharT
* __lhs
,
2233 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2236 * @brief Concatenate character and string.
2237 * @param __lhs First string.
2238 * @param __rhs Last string.
2239 * @return New string with @a __lhs followed by @a __rhs.
2241 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2242 template <typename
, typename
, typename
> class _Base
>
2243 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2244 operator+(_CharT __lhs
,
2245 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2248 * @brief Concatenate string and C string.
2249 * @param __lhs First string.
2250 * @param __rhs Last string.
2251 * @return New string with @a __lhs followed by @a __rhs.
2253 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2254 template <typename
, typename
, typename
> class _Base
>
2255 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2256 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2257 const _CharT
* __rhs
);
2260 * @brief Concatenate string and character.
2261 * @param __lhs First string.
2262 * @param __rhs Last string.
2263 * @return New string with @a __lhs followed by @a __rhs.
2265 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2266 template <typename
, typename
, typename
> class _Base
>
2267 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2268 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2271 #if __cplusplus >= 201103L
2272 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2273 template <typename
, typename
, typename
> class _Base
>
2274 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2275 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2276 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2277 { return std::move(__lhs
.append(__rhs
)); }
2279 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2280 template <typename
, typename
, typename
> class _Base
>
2281 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2282 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2283 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2284 { return std::move(__rhs
.insert(0, __lhs
)); }
2286 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2287 template <typename
, typename
, typename
> class _Base
>
2288 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2289 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2290 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2292 const auto __size
= __lhs
.size() + __rhs
.size();
2293 const bool __cond
= (__size
> __lhs
.capacity()
2294 && __size
<= __rhs
.capacity());
2295 return __cond
? std::move(__rhs
.insert(0, __lhs
))
2296 : std::move(__lhs
.append(__rhs
));
2299 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2300 template <typename
, typename
, typename
> class _Base
>
2301 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2302 operator+(const _CharT
* __lhs
,
2303 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2304 { return std::move(__rhs
.insert(0, __lhs
)); }
2306 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2307 template <typename
, typename
, typename
> class _Base
>
2308 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2309 operator+(_CharT __lhs
,
2310 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2311 { return std::move(__rhs
.insert(0, 1, __lhs
)); }
2313 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2314 template <typename
, typename
, typename
> class _Base
>
2315 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2316 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2317 const _CharT
* __rhs
)
2318 { return std::move(__lhs
.append(__rhs
)); }
2320 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2321 template <typename
, typename
, typename
> class _Base
>
2322 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2323 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2325 { return std::move(__lhs
.append(1, __rhs
)); }
2330 * @brief Test equivalence of two strings.
2331 * @param __lhs First string.
2332 * @param __rhs Second string.
2333 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2335 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2336 template <typename
, typename
, typename
> class _Base
>
2338 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2339 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2340 { return __lhs
.compare(__rhs
) == 0; }
2342 template<typename _CharT
,
2343 template <typename
, typename
, typename
> class _Base
>
2344 inline typename __enable_if
<std::__is_char
<_CharT
>::__value
, bool>::__type
2345 operator==(const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2346 std::allocator
<_CharT
>, _Base
>& __lhs
,
2347 const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2348 std::allocator
<_CharT
>, _Base
>& __rhs
)
2349 { return (__lhs
.size() == __rhs
.size()
2350 && !std::char_traits
<_CharT
>::compare(__lhs
.data(), __rhs
.data(),
2354 * @brief Test equivalence of C string and string.
2355 * @param __lhs C string.
2356 * @param __rhs String.
2357 * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise.
2359 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2360 template <typename
, typename
, typename
> class _Base
>
2362 operator==(const _CharT
* __lhs
,
2363 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2364 { return __rhs
.compare(__lhs
) == 0; }
2367 * @brief Test equivalence of string and C string.
2368 * @param __lhs String.
2369 * @param __rhs C string.
2370 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2372 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2373 template <typename
, typename
, typename
> class _Base
>
2375 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2376 const _CharT
* __rhs
)
2377 { return __lhs
.compare(__rhs
) == 0; }
2381 * @brief Test difference of two strings.
2382 * @param __lhs First string.
2383 * @param __rhs Second string.
2384 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2386 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2387 template <typename
, typename
, typename
> class _Base
>
2389 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2390 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2391 { return !(__lhs
== __rhs
); }
2394 * @brief Test difference of C string and string.
2395 * @param __lhs C string.
2396 * @param __rhs String.
2397 * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise.
2399 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2400 template <typename
, typename
, typename
> class _Base
>
2402 operator!=(const _CharT
* __lhs
,
2403 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2404 { return !(__lhs
== __rhs
); }
2407 * @brief Test difference of string and C string.
2408 * @param __lhs String.
2409 * @param __rhs C string.
2410 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2412 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2413 template <typename
, typename
, typename
> class _Base
>
2415 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2416 const _CharT
* __rhs
)
2417 { return !(__lhs
== __rhs
); }
2421 * @brief Test if string precedes string.
2422 * @param __lhs First string.
2423 * @param __rhs Second string.
2424 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2426 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2427 template <typename
, typename
, typename
> class _Base
>
2429 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2430 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2431 { return __lhs
.compare(__rhs
) < 0; }
2434 * @brief Test if string precedes C string.
2435 * @param __lhs String.
2436 * @param __rhs C string.
2437 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2439 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2440 template <typename
, typename
, typename
> class _Base
>
2442 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2443 const _CharT
* __rhs
)
2444 { return __lhs
.compare(__rhs
) < 0; }
2447 * @brief Test if C string precedes string.
2448 * @param __lhs C string.
2449 * @param __rhs String.
2450 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2452 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2453 template <typename
, typename
, typename
> class _Base
>
2455 operator<(const _CharT
* __lhs
,
2456 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2457 { return __rhs
.compare(__lhs
) > 0; }
2461 * @brief Test if string follows string.
2462 * @param __lhs First string.
2463 * @param __rhs Second string.
2464 * @return True if @a __lhs follows @a __rhs. False otherwise.
2466 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2467 template <typename
, typename
, typename
> class _Base
>
2469 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2470 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2471 { return __lhs
.compare(__rhs
) > 0; }
2474 * @brief Test if string follows C string.
2475 * @param __lhs String.
2476 * @param __rhs C string.
2477 * @return True if @a __lhs follows @a __rhs. False otherwise.
2479 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2480 template <typename
, typename
, typename
> class _Base
>
2482 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2483 const _CharT
* __rhs
)
2484 { return __lhs
.compare(__rhs
) > 0; }
2487 * @brief Test if C string follows string.
2488 * @param __lhs C string.
2489 * @param __rhs String.
2490 * @return True if @a __lhs follows @a __rhs. False otherwise.
2492 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2493 template <typename
, typename
, typename
> class _Base
>
2495 operator>(const _CharT
* __lhs
,
2496 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2497 { return __rhs
.compare(__lhs
) < 0; }
2501 * @brief Test if string doesn't follow string.
2502 * @param __lhs First string.
2503 * @param __rhs Second string.
2504 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2506 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2507 template <typename
, typename
, typename
> class _Base
>
2509 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2510 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2511 { return __lhs
.compare(__rhs
) <= 0; }
2514 * @brief Test if string doesn't follow C string.
2515 * @param __lhs String.
2516 * @param __rhs C string.
2517 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2519 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2520 template <typename
, typename
, typename
> class _Base
>
2522 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2523 const _CharT
* __rhs
)
2524 { return __lhs
.compare(__rhs
) <= 0; }
2527 * @brief Test if C string doesn't follow string.
2528 * @param __lhs C string.
2529 * @param __rhs String.
2530 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2532 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2533 template <typename
, typename
, typename
> class _Base
>
2535 operator<=(const _CharT
* __lhs
,
2536 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2537 { return __rhs
.compare(__lhs
) >= 0; }
2541 * @brief Test if string doesn't precede string.
2542 * @param __lhs First string.
2543 * @param __rhs Second string.
2544 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2546 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2547 template <typename
, typename
, typename
> class _Base
>
2549 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2550 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2551 { return __lhs
.compare(__rhs
) >= 0; }
2554 * @brief Test if string doesn't precede C string.
2555 * @param __lhs String.
2556 * @param __rhs C string.
2557 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2559 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2560 template <typename
, typename
, typename
> class _Base
>
2562 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2563 const _CharT
* __rhs
)
2564 { return __lhs
.compare(__rhs
) >= 0; }
2567 * @brief Test if C string doesn't precede string.
2568 * @param __lhs C string.
2569 * @param __rhs String.
2570 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2572 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2573 template <typename
, typename
, typename
> class _Base
>
2575 operator>=(const _CharT
* __lhs
,
2576 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2577 { return __rhs
.compare(__lhs
) <= 0; }
2580 * @brief Swap contents of two strings.
2581 * @param __lhs First string.
2582 * @param __rhs Second string.
2584 * Exchanges the contents of @a __lhs and @a __rhs in constant time.
2586 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2587 template <typename
, typename
, typename
> class _Base
>
2589 swap(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2590 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2591 { __lhs
.swap(__rhs
); }
2593 _GLIBCXX_END_NAMESPACE_VERSION
2596 namespace std
_GLIBCXX_VISIBILITY(default)
2598 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2601 * @brief Read stream into a string.
2602 * @param __is Input stream.
2603 * @param __str Buffer to store into.
2604 * @return Reference to the input stream.
2606 * Stores characters from @a __is into @a __str until whitespace is
2607 * found, the end of the stream is encountered, or str.max_size()
2608 * is reached. If is.width() is non-zero, that is the limit on the
2609 * number of characters stored into @a __str. Any previous
2610 * contents of @a __str are erased.
2612 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2613 template <typename
, typename
, typename
> class _Base
>
2614 basic_istream
<_CharT
, _Traits
>&
2615 operator>>(basic_istream
<_CharT
, _Traits
>& __is
,
2616 __gnu_cxx::__versa_string
<_CharT
, _Traits
,
2617 _Alloc
, _Base
>& __str
);
2620 * @brief Write string to a stream.
2621 * @param __os Output stream.
2622 * @param __str String to write out.
2623 * @return Reference to the output stream.
2625 * Output characters of @a __str into os following the same rules as for
2626 * writing a C string.
2628 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2629 template <typename
, typename
, typename
> class _Base
>
2630 inline basic_ostream
<_CharT
, _Traits
>&
2631 operator<<(basic_ostream
<_CharT
, _Traits
>& __os
,
2632 const __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
,
2635 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2636 // 586. string inserter not a formatted function
2637 return __ostream_insert(__os
, __str
.data(), __str
.size());
2641 * @brief Read a line from stream into a string.
2642 * @param __is Input stream.
2643 * @param __str Buffer to store into.
2644 * @param __delim Character marking end of line.
2645 * @return Reference to the input stream.
2647 * Stores characters from @a __is into @a __str until @a __delim is
2648 * found, the end of the stream is encountered, or str.max_size()
2649 * is reached. If is.width() is non-zero, that is the limit on the
2650 * number of characters stored into @a __str. Any previous
2651 * contents of @a __str are erased. If @a delim was encountered,
2652 * it is extracted but not stored into @a __str.
2654 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2655 template <typename
, typename
, typename
> class _Base
>
2656 basic_istream
<_CharT
, _Traits
>&
2657 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2658 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
,
2662 * @brief Read a line from stream into a string.
2663 * @param __is Input stream.
2664 * @param __str Buffer to store into.
2665 * @return Reference to the input stream.
2667 * Stores characters from is into @a __str until '\n' is
2668 * found, the end of the stream is encountered, or str.max_size()
2669 * is reached. If is.width() is non-zero, that is the limit on the
2670 * number of characters stored into @a __str. Any previous
2671 * contents of @a __str are erased. If end of line was
2672 * encountered, it is extracted but not stored into @a __str.
2674 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2675 template <typename
, typename
, typename
> class _Base
>
2676 inline basic_istream
<_CharT
, _Traits
>&
2677 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2678 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
)
2679 { return getline(__is
, __str
, __is
.widen('\n')); }
2681 _GLIBCXX_END_NAMESPACE_VERSION
2684 #if __cplusplus >= 201103L
2686 #include <ext/string_conversions.h>
2688 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
2690 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2692 #if _GLIBCXX_USE_C99_STDLIB
2693 // 21.4 Numeric Conversions [string.conversions].
2695 stoi(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2696 { return __gnu_cxx::__stoa
<long, int>(&std::strtol
, "stoi", __str
.c_str(),
2700 stol(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2701 { return __gnu_cxx::__stoa(&std::strtol
, "stol", __str
.c_str(),
2704 inline unsigned long
2705 stoul(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2706 { return __gnu_cxx::__stoa(&std::strtoul
, "stoul", __str
.c_str(),
2710 stoll(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2711 { return __gnu_cxx::__stoa(&std::strtoll
, "stoll", __str
.c_str(),
2714 inline unsigned long long
2715 stoull(const __vstring
& __str
, std::size_t* __idx
, int __base
= 10)
2716 { return __gnu_cxx::__stoa(&std::strtoull
, "stoull", __str
.c_str(),
2719 // NB: strtof vs strtod.
2721 stof(const __vstring
& __str
, std::size_t* __idx
= 0)
2722 { return __gnu_cxx::__stoa(&std::strtof
, "stof", __str
.c_str(), __idx
); }
2725 stod(const __vstring
& __str
, std::size_t* __idx
= 0)
2726 { return __gnu_cxx::__stoa(&std::strtod
, "stod", __str
.c_str(), __idx
); }
2729 stold(const __vstring
& __str
, std::size_t* __idx
= 0)
2730 { return __gnu_cxx::__stoa(&std::strtold
, "stold", __str
.c_str(), __idx
); }
2731 #endif // _GLIBCXX_USE_C99_STDLIB
2733 #if _GLIBCXX_USE_C99_STDIO
2734 // NB: (v)snprintf vs sprintf.
2738 to_string(int __val
)
2739 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, 4 * sizeof(int),
2743 to_string(unsigned __val
)
2744 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2745 4 * sizeof(unsigned),
2749 to_string(long __val
)
2750 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2755 to_string(unsigned long __val
)
2756 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2757 4 * sizeof(unsigned long),
2762 to_string(long long __val
)
2763 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2764 4 * sizeof(long long),
2768 to_string(unsigned long long __val
)
2769 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2770 4 * sizeof(unsigned long long),
2774 to_string(float __val
)
2776 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2777 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2782 to_string(double __val
)
2784 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2785 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2790 to_string(long double __val
)
2792 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2793 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2796 #endif // _GLIBCXX_USE_C99_STDIO
2798 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
2800 stoi(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2801 { return __gnu_cxx::__stoa
<long, int>(&std::wcstol
, "stoi", __str
.c_str(),
2805 stol(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2806 { return __gnu_cxx::__stoa(&std::wcstol
, "stol", __str
.c_str(),
2809 inline unsigned long
2810 stoul(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2811 { return __gnu_cxx::__stoa(&std::wcstoul
, "stoul", __str
.c_str(),
2815 stoll(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2816 { return __gnu_cxx::__stoa(&std::wcstoll
, "stoll", __str
.c_str(),
2819 inline unsigned long long
2820 stoull(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2821 { return __gnu_cxx::__stoa(&std::wcstoull
, "stoull", __str
.c_str(),
2824 // NB: wcstof vs wcstod.
2826 stof(const __wvstring
& __str
, std::size_t* __idx
= 0)
2827 { return __gnu_cxx::__stoa(&std::wcstof
, "stof", __str
.c_str(), __idx
); }
2830 stod(const __wvstring
& __str
, std::size_t* __idx
= 0)
2831 { return __gnu_cxx::__stoa(&std::wcstod
, "stod", __str
.c_str(), __idx
); }
2834 stold(const __wvstring
& __str
, std::size_t* __idx
= 0)
2835 { return __gnu_cxx::__stoa(&std::wcstold
, "stold", __str
.c_str(), __idx
); }
2837 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2840 to_wstring(int __val
)
2841 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2846 to_wstring(unsigned __val
)
2847 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2848 4 * sizeof(unsigned),
2852 to_wstring(long __val
)
2853 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2858 to_wstring(unsigned long __val
)
2859 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2860 4 * sizeof(unsigned long),
2864 to_wstring(long long __val
)
2865 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2866 4 * sizeof(long long),
2870 to_wstring(unsigned long long __val
)
2871 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2872 4 * sizeof(unsigned long long),
2876 to_wstring(float __val
)
2878 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2879 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2884 to_wstring(double __val
)
2886 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2887 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2892 to_wstring(long double __val
)
2894 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2895 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2898 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2899 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
2901 _GLIBCXX_END_NAMESPACE_VERSION
2906 #if __cplusplus >= 201103L
2908 #include <bits/functional_hash.h>
2910 namespace std
_GLIBCXX_VISIBILITY(default)
2912 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2914 /// std::hash specialization for __vstring.
2916 struct hash
<__gnu_cxx::__vstring
>
2917 : public __hash_base
<size_t, __gnu_cxx::__vstring
>
2920 operator()(const __gnu_cxx::__vstring
& __s
) const noexcept
2921 { return std::_Hash_impl::hash(__s
.data(), __s
.length()); }
2924 #ifdef _GLIBCXX_USE_WCHAR_T
2925 /// std::hash specialization for __wvstring.
2927 struct hash
<__gnu_cxx::__wvstring
>
2928 : public __hash_base
<size_t, __gnu_cxx::__wvstring
>
2931 operator()(const __gnu_cxx::__wvstring
& __s
) const noexcept
2932 { return std::_Hash_impl::hash(__s
.data(),
2933 __s
.length() * sizeof(wchar_t)); }
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
)); }
2959 _GLIBCXX_END_NAMESPACE_VERSION
2964 #include <ext/vstring.tcc>
2966 #endif /* _VSTRING_H */