1 // Versatile string -*- C++ -*-
3 // Copyright (C) 2005-2022 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file ext/vstring.h
26 * This file is a GNU extension to the Standard C++ Library.
32 #pragma GCC system_header
34 #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>
41 #include <bits/stl_algobase.h> // std::min
43 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 * @class __versa_string vstring.h
49 * @brief Template class __versa_string.
52 * Data structure managing sequences of characters and
53 * character-like objects.
55 template<typename _CharT
, typename _Traits
, typename _Alloc
,
56 template <typename
, typename
, typename
> class _Base
>
58 : private _Base
<_CharT
, _Traits
, _Alloc
>
60 typedef _Base
<_CharT
, _Traits
, _Alloc
> __vstring_base
;
61 typedef typename
__vstring_base::_CharT_alloc_type _CharT_alloc_type
;
62 typedef __alloc_traits
<_CharT_alloc_type
> _CharT_alloc_traits
;
66 typedef _Traits traits_type
;
67 typedef typename
_Traits::char_type value_type
;
68 typedef _Alloc allocator_type
;
69 typedef typename
_CharT_alloc_type::size_type size_type
;
70 typedef typename
_CharT_alloc_type::difference_type difference_type
;
71 typedef value_type
& reference
;
72 typedef const value_type
& const_reference
;
73 typedef typename
_CharT_alloc_traits::pointer pointer
;
74 typedef typename
_CharT_alloc_traits::const_pointer const_pointer
;
75 typedef __gnu_cxx::__normal_iterator
<pointer
, __versa_string
> iterator
;
76 typedef __gnu_cxx::__normal_iterator
<const_pointer
, __versa_string
>
78 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
79 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
81 // Data Member (public):
82 /// Value returned by various member functions when they fail.
83 static const size_type npos
= static_cast<size_type
>(-1);
87 _M_check(size_type __pos
, const char* __s
) const
89 if (__pos
> this->size())
90 std::__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
91 "this->size() (which is %zu)"),
92 __s
, __pos
, this->size());
97 _M_check_length(size_type __n1
, size_type __n2
, const char* __s
) const
99 if (this->max_size() - (this->size() - __n1
) < __n2
)
100 std::__throw_length_error(__N(__s
));
103 // NB: _M_limit doesn't check for a bad __pos value.
105 _M_limit(size_type __pos
, size_type __off
) const _GLIBCXX_NOEXCEPT
107 const bool __testoff
= __off
< this->size() - __pos
;
108 return __testoff
? __off
: this->size() - __pos
;
111 // True if _Rep and source do not overlap.
113 _M_disjunct(const _CharT
* __s
) const _GLIBCXX_NOEXCEPT
115 return (std::less
<const _CharT
*>()(__s
, this->_M_data())
116 || std::less
<const _CharT
*>()(this->_M_data()
117 + this->size(), __s
));
120 // For the internal use we have functions similar to `begin'/`end'
121 // but they do not call _M_leak.
123 _M_ibegin() const _GLIBCXX_NOEXCEPT
124 { return iterator(this->_M_data()); }
127 _M_iend() const _GLIBCXX_NOEXCEPT
128 { return iterator(this->_M_data() + this->_M_length()); }
131 // Construct/copy/destroy:
132 // NB: We overload ctors in some cases instead of using default
133 // arguments, per 17.4.4.4 para. 2 item 2.
136 * @brief Construct an empty string using allocator @a a.
139 __versa_string(const _Alloc
& __a
= _Alloc()) _GLIBCXX_NOEXCEPT
140 : __vstring_base(__a
) { }
142 // NB: per LWG issue 42, semantics different from IS:
144 * @brief Construct string with copy of value of @a __str.
145 * @param __str Source string.
147 __versa_string(const __versa_string
& __str
)
148 : __vstring_base(__str
) { }
150 #if __cplusplus >= 201103L
152 * @brief String move constructor.
153 * @param __str Source string.
155 * The newly-constructed %string contains the exact contents of
156 * @a __str. The contents of @a __str are a valid, but unspecified
159 __versa_string(__versa_string
&& __str
) noexcept
160 : __vstring_base(std::move(__str
)) { }
163 * @brief Construct string from an initializer list.
164 * @param __l std::initializer_list of characters.
165 * @param __a Allocator to use (default is default allocator).
167 __versa_string(std::initializer_list
<_CharT
> __l
,
168 const _Alloc
& __a
= _Alloc())
169 : __vstring_base(__l
.begin(), __l
.end(), __a
) { }
173 * @brief Construct string as copy of a substring.
174 * @param __str Source string.
175 * @param __pos Index of first character to copy from.
176 * @param __n Number of characters to copy (default remainder).
178 __versa_string(const __versa_string
& __str
, size_type __pos
,
179 size_type __n
= npos
)
180 : __vstring_base(__str
._M_data()
181 + __str
._M_check(__pos
,
182 "__versa_string::__versa_string"),
183 __str
._M_data() + __str
._M_limit(__pos
, __n
)
184 + __pos
, _Alloc()) { }
187 * @brief Construct string as copy of a substring.
188 * @param __str Source string.
189 * @param __pos Index of first character to copy from.
190 * @param __n Number of characters to copy.
191 * @param __a Allocator to use.
193 __versa_string(const __versa_string
& __str
, size_type __pos
,
194 size_type __n
, const _Alloc
& __a
)
195 : __vstring_base(__str
._M_data()
196 + __str
._M_check(__pos
,
197 "__versa_string::__versa_string"),
198 __str
._M_data() + __str
._M_limit(__pos
, __n
)
202 * @brief Construct string initialized by a character array.
203 * @param __s Source character array.
204 * @param __n Number of characters to copy.
205 * @param __a Allocator to use (default is default allocator).
207 * NB: @a __s must have at least @a __n characters, '\\0' has no special
210 __versa_string(const _CharT
* __s
, size_type __n
,
211 const _Alloc
& __a
= _Alloc())
212 : __vstring_base(__s
, __s
+ __n
, __a
) { }
215 * @brief Construct string as copy of a C string.
216 * @param __s Source C string.
217 * @param __a Allocator to use (default is default allocator).
219 __versa_string(const _CharT
* __s
, const _Alloc
& __a
= _Alloc())
220 : __vstring_base(__s
, __s
? __s
+ traits_type::length(__s
) :
224 * @brief Construct string as multiple characters.
225 * @param __n Number of characters.
226 * @param __c Character to use.
227 * @param __a Allocator to use (default is default allocator).
229 __versa_string(size_type __n
, _CharT __c
, const _Alloc
& __a
= _Alloc())
230 : __vstring_base(__n
, __c
, __a
) { }
233 * @brief Construct string as copy of a range.
234 * @param __beg Start of range.
235 * @param __end End of range.
236 * @param __a Allocator to use (default is default allocator).
238 #if __cplusplus >= 201103L
239 template<class _InputIterator
,
240 typename
= std::_RequireInputIter
<_InputIterator
>>
242 template<class _InputIterator
>
244 __versa_string(_InputIterator __beg
, _InputIterator __end
,
245 const _Alloc
& __a
= _Alloc())
246 : __vstring_base(__beg
, __end
, __a
) { }
249 * @brief Destroy the string instance.
251 ~__versa_string() _GLIBCXX_NOEXCEPT
{ }
254 * @brief Assign the value of @a str to this string.
255 * @param __str Source string.
258 operator=(const __versa_string
& __str
)
259 { return this->assign(__str
); }
261 #if __cplusplus >= 201103L
263 * @brief String move assignment operator.
264 * @param __str Source string.
266 * The contents of @a __str are moved into this string (without
267 * copying). @a __str is a valid, but unspecified string.
270 operator=(__versa_string
&& __str
) noexcept
278 * @brief Set value to string constructed from initializer list.
279 * @param __l std::initializer_list.
282 operator=(std::initializer_list
<_CharT
> __l
)
284 this->assign(__l
.begin(), __l
.end());
290 * @brief Copy contents of @a __s into this string.
291 * @param __s Source null-terminated string.
294 operator=(const _CharT
* __s
)
295 { return this->assign(__s
); }
298 * @brief Set value to string of length 1.
299 * @param __c Source character.
301 * Assigning to a character makes this string length 1 and
302 * (*this)[0] == @a __c.
305 operator=(_CharT __c
)
307 this->assign(1, __c
);
313 * Returns a read/write iterator that points to the first character in
314 * the %string. Unshares the string.
317 begin() _GLIBCXX_NOEXCEPT
320 return iterator(this->_M_data());
324 * Returns a read-only (constant) iterator that points to the first
325 * character in the %string.
328 begin() const _GLIBCXX_NOEXCEPT
329 { return const_iterator(this->_M_data()); }
332 * Returns a read/write iterator that points one past the last
333 * character in the %string. Unshares the string.
336 end() _GLIBCXX_NOEXCEPT
339 return iterator(this->_M_data() + this->size());
343 * Returns a read-only (constant) iterator that points one past the
344 * last character in the %string.
347 end() const _GLIBCXX_NOEXCEPT
348 { return const_iterator(this->_M_data() + this->size()); }
351 * Returns a read/write reverse iterator that points to the last
352 * character in the %string. Iteration is done in reverse element
353 * order. Unshares the string.
356 rbegin() _GLIBCXX_NOEXCEPT
357 { return reverse_iterator(this->end()); }
360 * Returns a read-only (constant) reverse iterator that points
361 * to the last character in the %string. Iteration is done in
362 * reverse element order.
364 const_reverse_iterator
365 rbegin() const _GLIBCXX_NOEXCEPT
366 { return const_reverse_iterator(this->end()); }
369 * Returns a read/write reverse iterator that points to one before the
370 * first character in the %string. Iteration is done in reverse
371 * element order. Unshares the string.
374 rend() _GLIBCXX_NOEXCEPT
375 { return reverse_iterator(this->begin()); }
378 * Returns a read-only (constant) reverse iterator that points
379 * to one before the first character in the %string. Iteration
380 * is done in reverse element order.
382 const_reverse_iterator
383 rend() const _GLIBCXX_NOEXCEPT
384 { return const_reverse_iterator(this->begin()); }
386 #if __cplusplus >= 201103L
388 * Returns a read-only (constant) iterator that points to the first
389 * character in the %string.
392 cbegin() const noexcept
393 { return const_iterator(this->_M_data()); }
396 * Returns a read-only (constant) iterator that points one past the
397 * last character in the %string.
400 cend() const noexcept
401 { return const_iterator(this->_M_data() + this->size()); }
404 * Returns a read-only (constant) reverse iterator that points
405 * to the last character in the %string. Iteration is done in
406 * reverse element order.
408 const_reverse_iterator
409 crbegin() const noexcept
410 { return const_reverse_iterator(this->end()); }
413 * Returns a read-only (constant) reverse iterator that points
414 * to one before the first character in the %string. Iteration
415 * is done in reverse element order.
417 const_reverse_iterator
418 crend() const noexcept
419 { return const_reverse_iterator(this->begin()); }
424 /// Returns the number of characters in the string, not including any
425 /// null-termination.
427 size() const _GLIBCXX_NOEXCEPT
428 { return this->_M_length(); }
430 /// Returns the number of characters in the string, not including any
431 /// null-termination.
433 length() const _GLIBCXX_NOEXCEPT
434 { return this->_M_length(); }
436 /// Returns the size() of the largest possible %string.
438 max_size() const _GLIBCXX_NOEXCEPT
439 { return this->_M_max_size(); }
442 * @brief Resizes the %string to the specified number of characters.
443 * @param __n Number of characters the %string should contain.
444 * @param __c Character to fill any new elements.
446 * This function will %resize the %string to the specified
447 * number of characters. If the number is smaller than the
448 * %string's current size the %string is truncated, otherwise
449 * the %string is extended and new elements are set to @a __c.
452 resize(size_type __n
, _CharT __c
);
455 * @brief Resizes the %string to the specified number of characters.
456 * @param __n Number of characters the %string should contain.
458 * This function will resize the %string to the specified
459 * length. If the new size is smaller than the %string's
460 * current size the %string is truncated, otherwise the %string
461 * is extended and new characters are default-constructed. For
462 * basic types such as char, this means setting them to 0.
465 resize(size_type __n
)
466 { this->resize(__n
, _CharT()); }
468 #if __cplusplus >= 201103L
469 /// A non-binding request to reduce capacity() to size().
471 shrink_to_fit() noexcept
473 if (capacity() > size())
476 { this->reserve(0); }
484 * Returns the total number of characters that the %string can
485 * hold before needing to allocate more memory.
488 capacity() const _GLIBCXX_NOEXCEPT
489 { return this->_M_capacity(); }
492 * @brief Attempt to preallocate enough memory for specified number of
494 * @param __res_arg Number of characters required.
495 * @throw std::length_error If @a __res_arg exceeds @c max_size().
497 * This function attempts to reserve enough memory for the
498 * %string to hold the specified number of characters. If the
499 * number requested is more than max_size(), length_error is
502 * The advantage of this function is that if optimal code is a
503 * necessity and the user can determine the string length that
504 * will be required, the user can reserve the memory in
505 * %advance, and thus prevent a possible reallocation of memory
506 * and copying of %string data.
509 reserve(size_type __res_arg
= 0)
510 { this->_M_reserve(__res_arg
); }
513 * Erases the string, making it empty.
516 clear() _GLIBCXX_NOEXCEPT
517 { this->_M_clear(); }
520 * Returns true if the %string is empty. Equivalent to
521 * <code>*this == ""</code>.
523 _GLIBCXX_NODISCARD
bool
524 empty() const _GLIBCXX_NOEXCEPT
525 { return this->size() == 0; }
529 * @brief Subscript access to the data contained in the %string.
530 * @param __pos The index of the character to access.
531 * @return Read-only (constant) reference to the character.
533 * This operator allows for easy, array-style, data access.
534 * Note that data access with this operator is unchecked and
535 * out_of_range lookups are not defined. (For checked lookups
539 operator[] (size_type __pos
) const _GLIBCXX_NOEXCEPT
541 __glibcxx_assert(__pos
<= this->size());
542 return this->_M_data()[__pos
];
546 * @brief Subscript access to the data contained in the %string.
547 * @param __pos The index of the character to access.
548 * @return Read/write reference to the character.
550 * This operator allows for easy, array-style, data access.
551 * Note that data access with this operator is unchecked and
552 * out_of_range lookups are not defined. (For checked lookups
553 * see at().) Unshares the string.
556 operator[](size_type __pos
) _GLIBCXX_NOEXCEPT
558 // Allow pos == size() both in C++98 mode, as v3 extension,
559 // and in C++11 mode.
560 __glibcxx_assert(__pos
<= this->size());
561 // In pedantic mode be strict in C++98 mode.
562 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus
>= 201103L
563 || __pos
< this->size());
565 return this->_M_data()[__pos
];
569 * @brief Provides access to the data contained in the %string.
570 * @param __n The index of the character to access.
571 * @return Read-only (const) reference to the character.
572 * @throw std::out_of_range If @a __n is an invalid index.
574 * This function provides for safer data access. The parameter
575 * is first checked that it is in the range of the string. The
576 * function throws out_of_range if the check fails.
579 at(size_type __n
) const
581 if (__n
>= this->size())
582 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
583 "(which is %zu) >= this->size() "
586 return this->_M_data()[__n
];
590 * @brief Provides access to the data contained in the %string.
591 * @param __n The index of the character to access.
592 * @return Read/write reference to the character.
593 * @throw std::out_of_range If @a __n is an invalid index.
595 * This function provides for safer data access. The parameter
596 * is first checked that it is in the range of the string. The
597 * function throws out_of_range if the check fails. Success
598 * results in unsharing the string.
603 if (__n
>= this->size())
604 std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
605 "(which is %zu) >= this->size() "
609 return this->_M_data()[__n
];
612 #if __cplusplus >= 201103L
614 * Returns a read/write reference to the data at the first
615 * element of the %string.
619 { return operator[](0); }
622 * Returns a read-only (constant) reference to the data at the first
623 * element of the %string.
626 front() const noexcept
627 { return operator[](0); }
630 * Returns a read/write reference to the data at the last
631 * element of the %string.
635 { return operator[](this->size() - 1); }
638 * Returns a read-only (constant) reference to the data at the
639 * last element of the %string.
642 back() const noexcept
643 { return operator[](this->size() - 1); }
648 * @brief Append a string to this string.
649 * @param __str The string to append.
650 * @return Reference to this string.
653 operator+=(const __versa_string
& __str
)
654 { return this->append(__str
); }
657 * @brief Append a C string.
658 * @param __s The C string to append.
659 * @return Reference to this string.
662 operator+=(const _CharT
* __s
)
663 { return this->append(__s
); }
666 * @brief Append a character.
667 * @param __c The character to append.
668 * @return Reference to this string.
671 operator+=(_CharT __c
)
673 this->push_back(__c
);
677 #if __cplusplus >= 201103L
679 * @brief Append an initializer_list of characters.
680 * @param __l The initializer_list of characters to be appended.
681 * @return Reference to this string.
684 operator+=(std::initializer_list
<_CharT
> __l
)
685 { return this->append(__l
.begin(), __l
.end()); }
689 * @brief Append a string to this string.
690 * @param __str The string to append.
691 * @return Reference to this string.
694 append(const __versa_string
& __str
)
695 { return _M_append(__str
._M_data(), __str
.size()); }
698 * @brief Append a substring.
699 * @param __str The string to append.
700 * @param __pos Index of the first character of str to append.
701 * @param __n The number of characters to append.
702 * @return Reference to this string.
703 * @throw std::out_of_range if @a pos is not a valid index.
705 * This function appends @a __n characters from @a __str
706 * starting at @a __pos to this string. If @a __n is is larger
707 * than the number of available characters in @a __str, the
708 * remainder of @a __str is appended.
711 append(const __versa_string
& __str
, size_type __pos
, size_type __n
)
712 { return _M_append(__str
._M_data()
713 + __str
._M_check(__pos
, "__versa_string::append"),
714 __str
._M_limit(__pos
, __n
)); }
717 * @brief Append a C substring.
718 * @param __s The C string to append.
719 * @param __n The number of characters to append.
720 * @return Reference to this string.
723 append(const _CharT
* __s
, size_type __n
)
725 __glibcxx_requires_string_len(__s
, __n
);
726 _M_check_length(size_type(0), __n
, "__versa_string::append");
727 return _M_append(__s
, __n
);
731 * @brief Append a C string.
732 * @param __s The C string to append.
733 * @return Reference to this string.
736 append(const _CharT
* __s
)
738 __glibcxx_requires_string(__s
);
739 const size_type __n
= traits_type::length(__s
);
740 _M_check_length(size_type(0), __n
, "__versa_string::append");
741 return _M_append(__s
, __n
);
745 * @brief Append multiple characters.
746 * @param __n The number of characters to append.
747 * @param __c The character to use.
748 * @return Reference to this string.
750 * Appends n copies of c to this string.
753 append(size_type __n
, _CharT __c
)
754 { return _M_replace_aux(this->size(), size_type(0), __n
, __c
); }
756 #if __cplusplus >= 201103L
758 * @brief Append an initializer_list of characters.
759 * @param __l The initializer_list of characters to append.
760 * @return Reference to this string.
763 append(std::initializer_list
<_CharT
> __l
)
764 { return this->append(__l
.begin(), __l
.end()); }
768 * @brief Append a range of characters.
769 * @param __first Iterator referencing the first character to append.
770 * @param __last Iterator marking the end of the range.
771 * @return Reference to this string.
773 * Appends characters in the range [first,last) to this string.
775 #if __cplusplus >= 201103L
776 template<class _InputIterator
,
777 typename
= std::_RequireInputIter
<_InputIterator
>>
779 template<class _InputIterator
>
782 append(_InputIterator __first
, _InputIterator __last
)
783 { return this->replace(_M_iend(), _M_iend(), __first
, __last
); }
786 * @brief Append a single character.
787 * @param __c Character to append.
790 push_back(_CharT __c
)
792 const size_type __size
= this->size();
793 if (__size
+ 1 > this->capacity() || this->_M_is_shared())
794 this->_M_mutate(__size
, size_type(0), 0, size_type(1));
795 traits_type::assign(this->_M_data()[__size
], __c
);
796 this->_M_set_length(__size
+ 1);
800 * @brief Set value to contents of another string.
801 * @param __str Source string to use.
802 * @return Reference to this string.
805 assign(const __versa_string
& __str
)
807 this->_M_assign(__str
);
811 #if __cplusplus >= 201103L
813 * @brief Set value to contents of another string.
814 * @param __str Source string to use.
815 * @return Reference to this string.
817 * This function sets this string to the exact contents of @a __str.
818 * @a __str is a valid, but unspecified string.
821 assign(__versa_string
&& __str
) noexcept
829 * @brief Set value to a substring of a string.
830 * @param __str The string to use.
831 * @param __pos Index of the first character of str.
832 * @param __n Number of characters to use.
833 * @return Reference to this string.
834 * @throw std::out_of_range if @a __pos is not a valid index.
836 * This function sets this string to the substring of @a __str
837 * consisting of @a __n characters at @a __pos. If @a __n is
838 * is larger than the number of available characters in @a
839 * __str, the remainder of @a __str is used.
842 assign(const __versa_string
& __str
, size_type __pos
, size_type __n
)
843 { return _M_replace(size_type(0), this->size(), __str
._M_data()
844 + __str
._M_check(__pos
, "__versa_string::assign"),
845 __str
._M_limit(__pos
, __n
)); }
848 * @brief Set value to a C substring.
849 * @param __s The C string to use.
850 * @param __n Number of characters to use.
851 * @return Reference to this string.
853 * This function sets the value of this string to the first @a
854 * __n characters of @a __s. If @a __n is is larger than the
855 * number of available characters in @a __s, the remainder of
859 assign(const _CharT
* __s
, size_type __n
)
861 __glibcxx_requires_string_len(__s
, __n
);
862 return _M_replace(size_type(0), this->size(), __s
, __n
);
866 * @brief Set value to contents of a C string.
867 * @param __s The C string to use.
868 * @return Reference to this string.
870 * This function sets the value of this string to the value of
871 * @a __s. The data is copied, so there is no dependence on @a
872 * __s once the function returns.
875 assign(const _CharT
* __s
)
877 __glibcxx_requires_string(__s
);
878 return _M_replace(size_type(0), this->size(), __s
,
879 traits_type::length(__s
));
883 * @brief Set value to multiple characters.
884 * @param __n Length of the resulting string.
885 * @param __c The character to use.
886 * @return Reference to this string.
888 * This function sets the value of this string to @a __n copies of
892 assign(size_type __n
, _CharT __c
)
893 { return _M_replace_aux(size_type(0), this->size(), __n
, __c
); }
896 * @brief Set value to a range of characters.
897 * @param __first Iterator referencing the first character to append.
898 * @param __last Iterator marking the end of the range.
899 * @return Reference to this string.
901 * Sets value of string to characters in the range
904 #if __cplusplus >= 201103L
905 template<class _InputIterator
,
906 typename
= std::_RequireInputIter
<_InputIterator
>>
908 template<class _InputIterator
>
911 assign(_InputIterator __first
, _InputIterator __last
)
912 { return this->replace(_M_ibegin(), _M_iend(), __first
, __last
); }
914 #if __cplusplus >= 201103L
916 * @brief Set value to an initializer_list of characters.
917 * @param __l The initializer_list of characters to assign.
918 * @return Reference to this string.
921 assign(std::initializer_list
<_CharT
> __l
)
922 { return this->assign(__l
.begin(), __l
.end()); }
925 #if __cplusplus >= 201103L
927 * @brief Insert multiple characters.
928 * @param __p Const_iterator referencing location in string to
930 * @param __n Number of characters to insert
931 * @param __c The character to insert.
932 * @return Iterator referencing the first inserted char.
933 * @throw std::length_error If new length exceeds @c max_size().
935 * Inserts @a __n copies of character @a __c starting at the
936 * position referenced by iterator @a __p. If adding
937 * characters causes the length to exceed max_size(),
938 * length_error is thrown. The value of the string doesn't
939 * change if an error is thrown.
942 insert(const_iterator __p
, size_type __n
, _CharT __c
)
944 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
945 const size_type __pos
= __p
- _M_ibegin();
946 this->replace(__p
, __p
, __n
, __c
);
947 return iterator(this->_M_data() + __pos
);
951 * @brief Insert multiple characters.
952 * @param __p Iterator referencing location in string to insert at.
953 * @param __n Number of characters to insert
954 * @param __c The character to insert.
955 * @throw std::length_error If new length exceeds @c max_size().
957 * Inserts @a __n copies of character @a __c starting at the
958 * position referenced by iterator @a __p. If adding
959 * characters causes the length to exceed max_size(),
960 * length_error is thrown. The value of the string doesn't
961 * change if an error is thrown.
964 insert(iterator __p
, size_type __n
, _CharT __c
)
965 { this->replace(__p
, __p
, __n
, __c
); }
968 #if __cplusplus >= 201103L
970 * @brief Insert a range of characters.
971 * @param __p Const_iterator referencing location in string to
973 * @param __beg Start of range.
974 * @param __end End of range.
975 * @return Iterator referencing the first inserted char.
976 * @throw std::length_error If new length exceeds @c max_size().
978 * Inserts characters in range [beg,end). If adding characters
979 * causes the length to exceed max_size(), length_error is
980 * thrown. The value of the string doesn't change if an error
983 template<class _InputIterator
,
984 typename
= std::_RequireInputIter
<_InputIterator
>>
986 insert(const_iterator __p
, _InputIterator __beg
, _InputIterator __end
)
988 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
989 const size_type __pos
= __p
- _M_ibegin();
990 this->replace(__p
, __p
, __beg
, __end
);
991 return iterator(this->_M_data() + __pos
);
995 * @brief Insert a range of characters.
996 * @param __p Iterator referencing location in string to insert at.
997 * @param __beg Start of range.
998 * @param __end End of range.
999 * @throw std::length_error If new length exceeds @c max_size().
1001 * Inserts characters in range [beg,end). If adding characters
1002 * causes the length to exceed max_size(), length_error is
1003 * thrown. The value of the string doesn't change if an error
1006 template<class _InputIterator
>
1008 insert(iterator __p
, _InputIterator __beg
, _InputIterator __end
)
1009 { this->replace(__p
, __p
, __beg
, __end
); }
1012 #if __cplusplus >= 201103L
1014 * @brief Insert an initializer_list of characters.
1015 * @param __p Const_iterator referencing location in string to
1017 * @param __l The initializer_list of characters to insert.
1018 * @return Iterator referencing the first inserted char.
1019 * @throw std::length_error If new length exceeds @c max_size().
1022 insert(const_iterator __p
, std::initializer_list
<_CharT
> __l
)
1023 { return this->insert(__p
, __l
.begin(), __l
.end()); }
1027 * @brief Insert value of a string.
1028 * @param __pos1 Iterator referencing location in string to insert at.
1029 * @param __str The string to insert.
1030 * @return Reference to this string.
1031 * @throw std::length_error If new length exceeds @c max_size().
1033 * Inserts value of @a __str starting at @a __pos1. If adding
1034 * characters causes the length to exceed max_size(),
1035 * length_error is thrown. The value of the string doesn't
1036 * change if an error is thrown.
1039 insert(size_type __pos1
, const __versa_string
& __str
)
1040 { return this->replace(__pos1
, size_type(0),
1041 __str
._M_data(), __str
.size()); }
1044 * @brief Insert a substring.
1045 * @param __pos1 Iterator referencing location in string to insert at.
1046 * @param __str The string to insert.
1047 * @param __pos2 Start of characters in str to insert.
1048 * @param __n Number of characters to insert.
1049 * @return Reference to this string.
1050 * @throw std::length_error If new length exceeds @c max_size().
1051 * @throw std::out_of_range If @a __pos1 > size() or
1052 * @a __pos2 > @a __str.size().
1054 * Starting at @a __pos1, insert @a __n character of @a __str
1055 * beginning with @a __pos2. If adding characters causes the
1056 * length to exceed max_size(), length_error is thrown. If @a
1057 * __pos1 is beyond the end of this string or @a __pos2 is
1058 * beyond the end of @a __str, out_of_range is thrown. The
1059 * value of the string doesn't change if an error is thrown.
1062 insert(size_type __pos1
, const __versa_string
& __str
,
1063 size_type __pos2
, size_type __n
)
1064 { return this->replace(__pos1
, size_type(0), __str
._M_data()
1065 + __str
._M_check(__pos2
, "__versa_string::insert"),
1066 __str
._M_limit(__pos2
, __n
)); }
1069 * @brief Insert a C substring.
1070 * @param __pos Iterator referencing location in string to insert at.
1071 * @param __s The C string to insert.
1072 * @param __n The number of characters to insert.
1073 * @return Reference to this string.
1074 * @throw std::length_error If new length exceeds @c max_size().
1075 * @throw std::out_of_range If @a __pos is beyond the end of this
1078 * Inserts the first @a __n characters of @a __s starting at @a
1079 * __pos. If adding characters causes the length to exceed
1080 * max_size(), length_error is thrown. If @a __pos is beyond
1081 * end(), out_of_range is thrown. The value of the string
1082 * doesn't change if an error is thrown.
1085 insert(size_type __pos
, const _CharT
* __s
, size_type __n
)
1086 { return this->replace(__pos
, size_type(0), __s
, __n
); }
1089 * @brief Insert a C string.
1090 * @param __pos Iterator referencing location in string to insert at.
1091 * @param __s The C string to insert.
1092 * @return Reference to this string.
1093 * @throw std::length_error If new length exceeds @c max_size().
1094 * @throw std::out_of_range If @a __pos is beyond the end of this
1097 * Inserts the first @a __n characters of @a __s starting at @a
1098 * __pos. If adding characters causes the length to exceed
1099 * max_size(), length_error is thrown. If @a __pos is beyond
1100 * end(), out_of_range is thrown. The value of the string
1101 * doesn't change if an error is thrown.
1104 insert(size_type __pos
, const _CharT
* __s
)
1106 __glibcxx_requires_string(__s
);
1107 return this->replace(__pos
, size_type(0), __s
,
1108 traits_type::length(__s
));
1112 * @brief Insert multiple characters.
1113 * @param __pos Index in string to insert at.
1114 * @param __n Number of characters to insert
1115 * @param __c The character to insert.
1116 * @return Reference to this string.
1117 * @throw std::length_error If new length exceeds @c max_size().
1118 * @throw std::out_of_range If @a __pos is beyond the end of this
1121 * Inserts @a __n copies of character @a __c starting at index
1122 * @a __pos. If adding characters causes the length to exceed
1123 * max_size(), length_error is thrown. If @a __pos > length(),
1124 * out_of_range is thrown. The value of the string doesn't
1125 * change if an error is thrown.
1128 insert(size_type __pos
, size_type __n
, _CharT __c
)
1129 { return _M_replace_aux(_M_check(__pos
, "__versa_string::insert"),
1130 size_type(0), __n
, __c
); }
1133 * @brief Insert one character.
1134 * @param __p Iterator referencing position in string to insert at.
1135 * @param __c The character to insert.
1136 * @return Iterator referencing newly inserted char.
1137 * @throw std::length_error If new length exceeds @c max_size().
1139 * Inserts character @a __c at position referenced by @a __p.
1140 * If adding character causes the length to exceed max_size(),
1141 * length_error is thrown. If @a __p is beyond end of string,
1142 * out_of_range is thrown. The value of the string doesn't
1143 * change if an error is thrown.
1146 #if __cplusplus >= 201103L
1147 insert(const_iterator __p
, _CharT __c
)
1149 insert(iterator __p
, _CharT __c
)
1152 _GLIBCXX_DEBUG_PEDASSERT(__p
>= _M_ibegin() && __p
<= _M_iend());
1153 const size_type __pos
= __p
- _M_ibegin();
1154 _M_replace_aux(__pos
, size_type(0), size_type(1), __c
);
1155 this->_M_set_leaked();
1156 return iterator(this->_M_data() + __pos
);
1160 * @brief Remove characters.
1161 * @param __pos Index of first character to remove (default 0).
1162 * @param __n Number of characters to remove (default remainder).
1163 * @return Reference to this string.
1164 * @throw std::out_of_range If @a __pos is beyond the end of this
1167 * Removes @a __n characters from this string starting at @a
1168 * __pos. The length of the string is reduced by @a __n. If
1169 * there are < @a __n characters to remove, the remainder of
1170 * the string is truncated. If @a __p is beyond end of string,
1171 * out_of_range is thrown. The value of the string doesn't
1172 * change if an error is thrown.
1175 erase(size_type __pos
= 0, size_type __n
= npos
)
1177 this->_M_erase(_M_check(__pos
, "__versa_string::erase"),
1178 _M_limit(__pos
, __n
));
1183 * @brief Remove one character.
1184 * @param __position Iterator referencing the character to remove.
1185 * @return iterator referencing same location after removal.
1187 * Removes the character at @a __position from this string. The
1188 * value of the string doesn't change if an error is thrown.
1191 #if __cplusplus >= 201103L
1192 erase(const_iterator __position
)
1194 erase(iterator __position
)
1197 _GLIBCXX_DEBUG_PEDASSERT(__position
>= _M_ibegin()
1198 && __position
< _M_iend());
1199 const size_type __pos
= __position
- _M_ibegin();
1200 this->_M_erase(__pos
, size_type(1));
1201 this->_M_set_leaked();
1202 return iterator(this->_M_data() + __pos
);
1206 * @brief Remove a range of characters.
1207 * @param __first Iterator referencing the first character to remove.
1208 * @param __last Iterator referencing the end of the range.
1209 * @return Iterator referencing location of first after removal.
1211 * Removes the characters in the range [first,last) from this
1212 * string. The value of the string doesn't change if an error
1216 #if __cplusplus >= 201103L
1217 erase(const_iterator __first
, const_iterator __last
)
1219 erase(iterator __first
, iterator __last
)
1222 _GLIBCXX_DEBUG_PEDASSERT(__first
>= _M_ibegin() && __first
<= __last
1223 && __last
<= _M_iend());
1224 const size_type __pos
= __first
- _M_ibegin();
1225 this->_M_erase(__pos
, __last
- __first
);
1226 this->_M_set_leaked();
1227 return iterator(this->_M_data() + __pos
);
1230 #if __cplusplus >= 201103L
1232 * @brief Remove the last character.
1234 * The string must be non-empty.
1238 { this->_M_erase(size()-1, 1); }
1242 * @brief Replace characters with value from another string.
1243 * @param __pos Index of first character to replace.
1244 * @param __n Number of characters to be replaced.
1245 * @param __str String to insert.
1246 * @return Reference to this string.
1247 * @throw std::out_of_range If @a __pos is beyond the end of this
1249 * @throw std::length_error If new length exceeds @c max_size().
1251 * Removes the characters in the range [pos,pos+n) from this
1252 * string. In place, the value of @a __str is inserted. If @a
1253 * __pos is beyond end of string, out_of_range is thrown. If
1254 * the length of the result exceeds max_size(), length_error is
1255 * thrown. The value of the string doesn't change if an error
1259 replace(size_type __pos
, size_type __n
, const __versa_string
& __str
)
1260 { return this->replace(__pos
, __n
, __str
._M_data(), __str
.size()); }
1263 * @brief Replace characters with value from another string.
1264 * @param __pos1 Index of first character to replace.
1265 * @param __n1 Number of characters to be replaced.
1266 * @param __str String to insert.
1267 * @param __pos2 Index of first character of str to use.
1268 * @param __n2 Number of characters from str to use.
1269 * @return Reference to this string.
1270 * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 >
1272 * @throw std::length_error If new length exceeds @c max_size().
1274 * Removes the characters in the range [pos1,pos1 + n) from
1275 * this string. In place, the value of @a __str is inserted.
1276 * If @a __pos is beyond end of string, out_of_range is thrown.
1277 * If the length of the result exceeds max_size(), length_error
1278 * is thrown. The value of the string doesn't change if an
1282 replace(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
1283 size_type __pos2
, size_type __n2
)
1285 return this->replace(__pos1
, __n1
, __str
._M_data()
1286 + __str
._M_check(__pos2
,
1287 "__versa_string::replace"),
1288 __str
._M_limit(__pos2
, __n2
));
1292 * @brief Replace characters with value of a C substring.
1293 * @param __pos Index of first character to replace.
1294 * @param __n1 Number of characters to be replaced.
1295 * @param __s C string to insert.
1296 * @param __n2 Number of characters from @a __s to use.
1297 * @return Reference to this string.
1298 * @throw std::out_of_range If @a __pos1 > size().
1299 * @throw std::length_error If new length exceeds @c max_size().
1301 * Removes the characters in the range [pos,pos + n1) from this
1302 * string. In place, the first @a __n2 characters of @a __s
1303 * are inserted, or all of @a __s if @a __n2 is too large. If
1304 * @a __pos is beyond end of string, out_of_range is thrown.
1305 * If the length of result exceeds max_size(), length_error is
1306 * thrown. The value of the string doesn't change if an error
1310 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
,
1313 __glibcxx_requires_string_len(__s
, __n2
);
1314 return _M_replace(_M_check(__pos
, "__versa_string::replace"),
1315 _M_limit(__pos
, __n1
), __s
, __n2
);
1319 * @brief Replace characters with value of a C string.
1320 * @param __pos Index of first character to replace.
1321 * @param __n1 Number of characters to be replaced.
1322 * @param __s C string to insert.
1323 * @return Reference to this string.
1324 * @throw std::out_of_range If @a __pos > size().
1325 * @throw std::length_error If new length exceeds @c max_size().
1327 * Removes the characters in the range [pos,pos + n1) from this
1328 * string. In place, the characters of @a __s are inserted. If
1329 * @a pos is beyond end of string, out_of_range is thrown. If
1330 * the length of result exceeds max_size(), length_error is thrown.
1331 * The value of the string doesn't change if an error is thrown.
1334 replace(size_type __pos
, size_type __n1
, const _CharT
* __s
)
1336 __glibcxx_requires_string(__s
);
1337 return this->replace(__pos
, __n1
, __s
, traits_type::length(__s
));
1341 * @brief Replace characters with multiple characters.
1342 * @param __pos Index of first character to replace.
1343 * @param __n1 Number of characters to be replaced.
1344 * @param __n2 Number of characters to insert.
1345 * @param __c Character to insert.
1346 * @return Reference to this string.
1347 * @throw std::out_of_range If @a __pos > size().
1348 * @throw std::length_error If new length exceeds @c max_size().
1350 * Removes the characters in the range [pos,pos + n1) from this
1351 * string. In place, @a __n2 copies of @a __c are inserted.
1352 * If @a __pos is beyond end of string, out_of_range is thrown.
1353 * If the length of result exceeds max_size(), length_error is
1354 * thrown. The value of the string doesn't change if an error
1358 replace(size_type __pos
, size_type __n1
, size_type __n2
, _CharT __c
)
1359 { return _M_replace_aux(_M_check(__pos
, "__versa_string::replace"),
1360 _M_limit(__pos
, __n1
), __n2
, __c
); }
1363 * @brief Replace range of characters with string.
1364 * @param __i1 Iterator referencing start of range to replace.
1365 * @param __i2 Iterator referencing end of range to replace.
1366 * @param __str String value to insert.
1367 * @return Reference to this string.
1368 * @throw std::length_error If new length exceeds @c max_size().
1370 * Removes the characters in the range [i1,i2). In place, the
1371 * value of @a __str is inserted. If the length of result
1372 * exceeds max_size(), length_error is thrown. The value of
1373 * the string doesn't change if an error is thrown.
1376 #if __cplusplus >= 201103L
1377 replace(const_iterator __i1
, const_iterator __i2
,
1378 const __versa_string
& __str
)
1380 replace(iterator __i1
, iterator __i2
, const __versa_string
& __str
)
1382 { return this->replace(__i1
, __i2
, __str
._M_data(), __str
.size()); }
1385 * @brief Replace range of characters with C substring.
1386 * @param __i1 Iterator referencing start of range to replace.
1387 * @param __i2 Iterator referencing end of range to replace.
1388 * @param __s C string value to insert.
1389 * @param __n Number of characters from s to insert.
1390 * @return Reference to this string.
1391 * @throw std::length_error If new length exceeds @c max_size().
1393 * Removes the characters in the range [i1,i2). In place, the
1394 * first @a n characters of @a __s are inserted. If the length
1395 * of result exceeds max_size(), length_error is thrown. The
1396 * value of the string doesn't change if an error is thrown.
1399 #if __cplusplus >= 201103L
1400 replace(const_iterator __i1
, const_iterator __i2
,
1401 const _CharT
* __s
, size_type __n
)
1403 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
, size_type __n
)
1406 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1407 && __i2
<= _M_iend());
1408 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
, __s
, __n
);
1412 * @brief Replace range of characters with C string.
1413 * @param __i1 Iterator referencing start of range to replace.
1414 * @param __i2 Iterator referencing end of range to replace.
1415 * @param __s C string value to insert.
1416 * @return Reference to this string.
1417 * @throw std::length_error If new length exceeds @c max_size().
1419 * Removes the characters in the range [i1,i2). In place, the
1420 * characters of @a __s are inserted. If the length of result
1421 * exceeds max_size(), length_error is thrown. The value of
1422 * the string doesn't change if an error is thrown.
1425 #if __cplusplus >= 201103L
1426 replace(const_iterator __i1
, const_iterator __i2
, const _CharT
* __s
)
1428 replace(iterator __i1
, iterator __i2
, const _CharT
* __s
)
1431 __glibcxx_requires_string(__s
);
1432 return this->replace(__i1
, __i2
, __s
, traits_type::length(__s
));
1436 * @brief Replace range of characters with multiple characters
1437 * @param __i1 Iterator referencing start of range to replace.
1438 * @param __i2 Iterator referencing end of range to replace.
1439 * @param __n Number of characters to insert.
1440 * @param __c Character to insert.
1441 * @return Reference to this string.
1442 * @throw std::length_error If new length exceeds @c max_size().
1444 * Removes the characters in the range [i1,i2). In place, @a
1445 * __n copies of @a __c are inserted. If the length of result
1446 * exceeds max_size(), length_error is thrown. The value of
1447 * the string doesn't change if an error is thrown.
1450 #if __cplusplus >= 201103L
1451 replace(const_iterator __i1
, const_iterator __i2
, size_type __n
,
1454 replace(iterator __i1
, iterator __i2
, size_type __n
, _CharT __c
)
1457 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1458 && __i2
<= _M_iend());
1459 return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __c
);
1463 * @brief Replace range of characters with range.
1464 * @param __i1 Iterator referencing start of range to replace.
1465 * @param __i2 Iterator referencing end of range to replace.
1466 * @param __k1 Iterator referencing start of range to insert.
1467 * @param __k2 Iterator referencing end of range to insert.
1468 * @return Reference to this string.
1469 * @throw std::length_error If new length exceeds @c max_size().
1471 * Removes the characters in the range [i1,i2). In place,
1472 * characters in the range [k1,k2) are inserted. If the length
1473 * of result exceeds max_size(), length_error is thrown. The
1474 * value of the string doesn't change if an error is thrown.
1476 #if __cplusplus >= 201103L
1477 template<class _InputIterator
,
1478 typename
= std::_RequireInputIter
<_InputIterator
>>
1480 replace(const_iterator __i1
, const_iterator __i2
,
1481 _InputIterator __k1
, _InputIterator __k2
)
1483 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1484 && __i2
<= _M_iend());
1485 __glibcxx_requires_valid_range(__k1
, __k2
);
1486 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
,
1487 std::__false_type());
1490 template<class _InputIterator
>
1492 replace(iterator __i1
, iterator __i2
,
1493 _InputIterator __k1
, _InputIterator __k2
)
1495 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1496 && __i2
<= _M_iend());
1497 __glibcxx_requires_valid_range(__k1
, __k2
);
1498 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
1499 return this->_M_replace_dispatch(__i1
, __i2
, __k1
, __k2
, _Integral());
1503 // Specializations for the common case of pointer and iterator:
1504 // useful to avoid the overhead of temporary buffering in _M_replace.
1506 #if __cplusplus >= 201103L
1507 replace(const_iterator __i1
, const_iterator __i2
,
1508 _CharT
* __k1
, _CharT
* __k2
)
1510 replace(iterator __i1
, iterator __i2
,
1511 _CharT
* __k1
, _CharT
* __k2
)
1514 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1515 && __i2
<= _M_iend());
1516 __glibcxx_requires_valid_range(__k1
, __k2
);
1517 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1522 #if __cplusplus >= 201103L
1523 replace(const_iterator __i1
, const_iterator __i2
,
1524 const _CharT
* __k1
, const _CharT
* __k2
)
1526 replace(iterator __i1
, iterator __i2
,
1527 const _CharT
* __k1
, const _CharT
* __k2
)
1530 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1531 && __i2
<= _M_iend());
1532 __glibcxx_requires_valid_range(__k1
, __k2
);
1533 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1538 #if __cplusplus >= 201103L
1539 replace(const_iterator __i1
, const_iterator __i2
,
1540 iterator __k1
, iterator __k2
)
1542 replace(iterator __i1
, iterator __i2
,
1543 iterator __k1
, iterator __k2
)
1546 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1547 && __i2
<= _M_iend());
1548 __glibcxx_requires_valid_range(__k1
, __k2
);
1549 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1550 __k1
.base(), __k2
- __k1
);
1554 #if __cplusplus >= 201103L
1555 replace(const_iterator __i1
, const_iterator __i2
,
1556 const_iterator __k1
, const_iterator __k2
)
1558 replace(iterator __i1
, iterator __i2
,
1559 const_iterator __k1
, const_iterator __k2
)
1562 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1
&& __i1
<= __i2
1563 && __i2
<= _M_iend());
1564 __glibcxx_requires_valid_range(__k1
, __k2
);
1565 return this->replace(__i1
- _M_ibegin(), __i2
- __i1
,
1566 __k1
.base(), __k2
- __k1
);
1569 #if __cplusplus >= 201103L
1571 * @brief Replace range of characters with initializer_list.
1572 * @param __i1 Iterator referencing start of range to replace.
1573 * @param __i2 Iterator referencing end of range to replace.
1574 * @param __l The initializer_list of characters to insert.
1575 * @return Reference to this string.
1576 * @throw std::length_error If new length exceeds @c max_size().
1578 * Removes the characters in the range [i1,i2). In place,
1579 * characters in the range [k1,k2) are inserted. If the length
1580 * of result exceeds max_size(), length_error is thrown. The
1581 * value of the string doesn't change if an error is thrown.
1584 replace(const_iterator __i1
, const_iterator __i2
,
1585 std::initializer_list
<_CharT
> __l
)
1586 { return this->replace(__i1
, __i2
, __l
.begin(), __l
.end()); }
1590 template<class _Integer
>
1592 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1593 _Integer __n
, _Integer __val
, std::__true_type
)
1594 { return _M_replace_aux(__i1
- _M_ibegin(), __i2
- __i1
, __n
, __val
); }
1596 template<class _InputIterator
>
1598 _M_replace_dispatch(const_iterator __i1
, const_iterator __i2
,
1599 _InputIterator __k1
, _InputIterator __k2
,
1603 _M_replace_aux(size_type __pos1
, size_type __n1
, size_type __n2
,
1607 _M_replace(size_type __pos
, size_type __len1
, const _CharT
* __s
,
1608 const size_type __len2
);
1611 _M_append(const _CharT
* __s
, size_type __n
);
1616 * @brief Copy substring into C string.
1617 * @param __s C string to copy value into.
1618 * @param __n Number of characters to copy.
1619 * @param __pos Index of first character to copy.
1620 * @return Number of characters actually copied
1621 * @throw std::out_of_range If pos > size().
1623 * Copies up to @a __n characters starting at @a __pos into the
1624 * C string @a s. If @a __pos is greater than size(),
1625 * out_of_range is thrown.
1628 copy(_CharT
* __s
, size_type __n
, size_type __pos
= 0) const;
1631 * @brief Swap contents with another string.
1632 * @param __s String to swap with.
1634 * Exchanges the contents of this string with that of @a __s in
1638 swap(__versa_string
& __s
) _GLIBCXX_NOEXCEPT
1639 { this->_M_swap(__s
); }
1641 // String operations:
1643 * @brief Return const pointer to null-terminated contents.
1645 * This is a handle to internal data. Do not modify or dire things may
1649 c_str() const _GLIBCXX_NOEXCEPT
1650 { return this->_M_data(); }
1653 * @brief Return const pointer to contents.
1655 * This is a handle to internal data. Do not modify or dire things may
1659 data() const _GLIBCXX_NOEXCEPT
1660 { return this->_M_data(); }
1663 * @brief Return copy of allocator used to construct this string.
1666 get_allocator() const _GLIBCXX_NOEXCEPT
1667 { return allocator_type(this->_M_get_allocator()); }
1670 * @brief Find position of a C substring.
1671 * @param __s C string to locate.
1672 * @param __pos Index of character to search from.
1673 * @param __n Number of characters from @a __s to search for.
1674 * @return Index of start of first occurrence.
1676 * Starting from @a __pos, searches forward for the first @a
1677 * __n characters in @a __s within this string. If found,
1678 * returns the index where it begins. If not found, returns
1682 find(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1685 * @brief Find position of a string.
1686 * @param __str String to locate.
1687 * @param __pos Index of character to search from (default 0).
1688 * @return Index of start of first occurrence.
1690 * Starting from @a __pos, searches forward for value of @a
1691 * __str within this string. If found, returns the index where
1692 * it begins. If not found, returns npos.
1695 find(const __versa_string
& __str
, size_type __pos
= 0) const
1697 { return this->find(__str
.data(), __pos
, __str
.size()); }
1700 * @brief Find position of a C string.
1701 * @param __s C string to locate.
1702 * @param __pos Index of character to search from (default 0).
1703 * @return Index of start of first occurrence.
1705 * Starting from @a __pos, searches forward for the value of @a
1706 * __s within this string. If found, returns the index where
1707 * it begins. If not found, returns npos.
1710 find(const _CharT
* __s
, size_type __pos
= 0) const
1712 __glibcxx_requires_string(__s
);
1713 return this->find(__s
, __pos
, traits_type::length(__s
));
1717 * @brief Find position of a character.
1718 * @param __c Character to locate.
1719 * @param __pos Index of character to search from (default 0).
1720 * @return Index of first occurrence.
1722 * Starting from @a __pos, searches forward for @a __c within
1723 * this string. If found, returns the index where it was
1724 * found. If not found, returns npos.
1727 find(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
;
1730 * @brief Find last position of a string.
1731 * @param __str String to locate.
1732 * @param __pos Index of character to search back from (default end).
1733 * @return Index of start of last occurrence.
1735 * Starting from @a __pos, searches backward for value of @a
1736 * __str within this string. If found, returns the index where
1737 * it begins. If not found, returns npos.
1740 rfind(const __versa_string
& __str
, size_type __pos
= npos
) const
1742 { return this->rfind(__str
.data(), __pos
, __str
.size()); }
1745 * @brief Find last position of a C substring.
1746 * @param __s C string to locate.
1747 * @param __pos Index of character to search back from.
1748 * @param __n Number of characters from s to search for.
1749 * @return Index of start of last occurrence.
1751 * Starting from @a __pos, searches backward for the first @a
1752 * __n characters in @a __s within this string. If found,
1753 * returns the index where it begins. If not found, returns
1757 rfind(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1760 * @brief Find last position of a C string.
1761 * @param __s C string to locate.
1762 * @param __pos Index of character to start search at (default end).
1763 * @return Index of start of last occurrence.
1765 * Starting from @a __pos, searches backward for the value of
1766 * @a __s within this string. If found, returns the index
1767 * where it begins. If not found, returns npos.
1770 rfind(const _CharT
* __s
, size_type __pos
= npos
) const
1772 __glibcxx_requires_string(__s
);
1773 return this->rfind(__s
, __pos
, traits_type::length(__s
));
1777 * @brief Find last position of a character.
1778 * @param __c Character to locate.
1779 * @param __pos Index of character to search back from (default end).
1780 * @return Index of last occurrence.
1782 * Starting from @a __pos, searches backward for @a __c within
1783 * this string. If found, returns the index where it was
1784 * found. If not found, returns npos.
1787 rfind(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
;
1790 * @brief Find position of a character of string.
1791 * @param __str String containing characters to locate.
1792 * @param __pos Index of character to search from (default 0).
1793 * @return Index of first occurrence.
1795 * Starting from @a __pos, searches forward for one of the characters of
1796 * @a __str within this string. If found, returns the index where it was
1797 * found. If not found, returns npos.
1800 find_first_of(const __versa_string
& __str
, size_type __pos
= 0) const
1802 { return this->find_first_of(__str
.data(), __pos
, __str
.size()); }
1805 * @brief Find position of a character of C substring.
1806 * @param __s String containing characters to locate.
1807 * @param __pos Index of character to search from.
1808 * @param __n Number of characters from s to search for.
1809 * @return Index of first occurrence.
1811 * Starting from @a __pos, searches forward for one of the
1812 * first @a __n characters of @a __s within this string. If
1813 * found, returns the index where it was found. If not found,
1817 find_first_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1820 * @brief Find position of a character of C string.
1821 * @param __s String containing characters to locate.
1822 * @param __pos Index of character to search from (default 0).
1823 * @return Index of first occurrence.
1825 * Starting from @a __pos, searches forward for one of the
1826 * characters of @a __s within this string. If found, returns
1827 * the index where it was found. If not found, returns npos.
1830 find_first_of(const _CharT
* __s
, size_type __pos
= 0) const
1832 __glibcxx_requires_string(__s
);
1833 return this->find_first_of(__s
, __pos
, traits_type::length(__s
));
1837 * @brief Find position of a character.
1838 * @param __c Character to locate.
1839 * @param __pos Index of character to search from (default 0).
1840 * @return Index of first occurrence.
1842 * Starting from @a __pos, searches forward for the character
1843 * @a __c within this string. If found, returns the index
1844 * where it was found. If not found, returns npos.
1846 * Note: equivalent to find(c, pos).
1849 find_first_of(_CharT __c
, size_type __pos
= 0) const _GLIBCXX_NOEXCEPT
1850 { return this->find(__c
, __pos
); }
1853 * @brief Find last position of a character of string.
1854 * @param __str String containing characters to locate.
1855 * @param __pos Index of character to search back from (default end).
1856 * @return Index of last occurrence.
1858 * Starting from @a __pos, searches backward for one of the
1859 * characters of @a __str within this string. If found,
1860 * returns the index where it was found. If not found, returns
1864 find_last_of(const __versa_string
& __str
, size_type __pos
= npos
) const
1866 { return this->find_last_of(__str
.data(), __pos
, __str
.size()); }
1869 * @brief Find last position of a character of C substring.
1870 * @param __s C string containing characters to locate.
1871 * @param __pos Index of character to search back from.
1872 * @param __n Number of characters from s to search for.
1873 * @return Index of last occurrence.
1875 * Starting from @a __pos, searches backward for one of the
1876 * first @a __n characters of @a __s within this string. If
1877 * found, returns the index where it was found. If not found,
1881 find_last_of(const _CharT
* __s
, size_type __pos
, size_type __n
) const;
1884 * @brief Find last position of a character of C string.
1885 * @param __s C string containing characters to locate.
1886 * @param __pos Index of character to search back from (default end).
1887 * @return Index of last occurrence.
1889 * Starting from @a __pos, searches backward for one of the
1890 * characters of @a __s within this string. If found, returns
1891 * the index where it was found. If not found, returns npos.
1894 find_last_of(const _CharT
* __s
, size_type __pos
= npos
) const
1896 __glibcxx_requires_string(__s
);
1897 return this->find_last_of(__s
, __pos
, traits_type::length(__s
));
1901 * @brief Find last position of a character.
1902 * @param __c Character to locate.
1903 * @param __pos Index of character to search back from (default end).
1904 * @return Index of last occurrence.
1906 * Starting from @a __pos, searches backward for @a __c within
1907 * this string. If found, returns the index where it was
1908 * found. If not found, returns npos.
1910 * Note: equivalent to rfind(c, pos).
1913 find_last_of(_CharT __c
, size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1914 { return this->rfind(__c
, __pos
); }
1917 * @brief Find position of a character not in string.
1918 * @param __str String containing characters to avoid.
1919 * @param __pos Index of character to search from (default 0).
1920 * @return Index of first occurrence.
1922 * Starting from @a __pos, searches forward for a character not
1923 * contained in @a __str within this string. If found, returns
1924 * the index where it was found. If not found, returns npos.
1927 find_first_not_of(const __versa_string
& __str
, size_type __pos
= 0) const
1929 { return this->find_first_not_of(__str
.data(), __pos
, __str
.size()); }
1932 * @brief Find position of a character not in C substring.
1933 * @param __s C string containing characters to avoid.
1934 * @param __pos Index of character to search from.
1935 * @param __n Number of characters from s to consider.
1936 * @return Index of first occurrence.
1938 * Starting from @a __pos, searches forward for a character not
1939 * contained in the first @a __n characters of @a __s within
1940 * this string. If found, returns the index where it was
1941 * found. If not found, returns npos.
1944 find_first_not_of(const _CharT
* __s
, size_type __pos
,
1945 size_type __n
) const;
1948 * @brief Find position of a character not in C string.
1949 * @param __s C string containing characters to avoid.
1950 * @param __pos Index of character to search from (default 0).
1951 * @return Index of first occurrence.
1953 * Starting from @a __pos, searches forward for a character not
1954 * contained in @a __s within this string. If found, returns
1955 * the index where it was found. If not found, returns npos.
1958 find_first_not_of(const _CharT
* __s
, size_type __pos
= 0) const
1960 __glibcxx_requires_string(__s
);
1961 return this->find_first_not_of(__s
, __pos
, traits_type::length(__s
));
1965 * @brief Find position of a different character.
1966 * @param __c Character to avoid.
1967 * @param __pos Index of character to search from (default 0).
1968 * @return Index of first occurrence.
1970 * Starting from @a __pos, searches forward for a character
1971 * other than @a __c within this string. If found, returns the
1972 * index where it was found. If not found, returns npos.
1975 find_first_not_of(_CharT __c
, size_type __pos
= 0) const
1979 * @brief Find last position of a character not in string.
1980 * @param __str String containing characters to avoid.
1981 * @param __pos Index of character to search back from (default end).
1982 * @return Index of last occurrence.
1984 * Starting from @a __pos, searches backward for a character
1985 * not contained in @a __str within this string. If found,
1986 * returns the index where it was found. If not found, returns
1990 find_last_not_of(const __versa_string
& __str
,
1991 size_type __pos
= npos
) const _GLIBCXX_NOEXCEPT
1992 { return this->find_last_not_of(__str
.data(), __pos
, __str
.size()); }
1995 * @brief Find last position of a character not in C substring.
1996 * @param __s C string containing characters to avoid.
1997 * @param __pos Index of character to search back from.
1998 * @param __n Number of characters from s to consider.
1999 * @return Index of last occurrence.
2001 * Starting from @a __pos, searches backward for a character
2002 * not contained in the first @a __n characters of @a __s
2003 * within this string. If found, returns the index where it
2004 * was found. If not found, returns npos.
2007 find_last_not_of(const _CharT
* __s
, size_type __pos
,
2008 size_type __n
) const;
2010 * @brief Find last position of a character not in C string.
2011 * @param __s C string containing characters to avoid.
2012 * @param __pos Index of character to search back from (default end).
2013 * @return Index of last occurrence.
2015 * Starting from @a __pos, searches backward for a character
2016 * not contained in @a __s within this string. If found,
2017 * returns the index where it was found. If not found, returns
2021 find_last_not_of(const _CharT
* __s
, size_type __pos
= npos
) const
2023 __glibcxx_requires_string(__s
);
2024 return this->find_last_not_of(__s
, __pos
, traits_type::length(__s
));
2028 * @brief Find last position of a different character.
2029 * @param __c Character to avoid.
2030 * @param __pos Index of character to search back from (default end).
2031 * @return Index of last occurrence.
2033 * Starting from @a __pos, searches backward for a character
2034 * other than @a __c within this string. If found, returns the
2035 * index where it was found. If not found, returns npos.
2038 find_last_not_of(_CharT __c
, size_type __pos
= npos
) const
2042 * @brief Get a substring.
2043 * @param __pos Index of first character (default 0).
2044 * @param __n Number of characters in substring (default remainder).
2045 * @return The new string.
2046 * @throw std::out_of_range If pos > size().
2048 * Construct and return a new string using the @a __n
2049 * characters starting at @a __pos. If the string is too
2050 * short, use the remainder of the characters. If @a __pos is
2051 * beyond the end of the string, out_of_range is thrown.
2054 substr(size_type __pos
= 0, size_type __n
= npos
) const
2056 return __versa_string(*this, _M_check(__pos
, "__versa_string::substr"),
2061 * @brief Compare to a string.
2062 * @param __str String to compare against.
2063 * @return Integer < 0, 0, or > 0.
2065 * Returns an integer < 0 if this string is ordered before @a
2066 * __str, 0 if their values are equivalent, or > 0 if this
2067 * string is ordered after @a __str. Determines the effective
2068 * length rlen of the strings to compare as the smallest of
2069 * size() and str.size(). The function then compares the two
2070 * strings by calling traits::compare(data(), str.data(),rlen).
2071 * If the result of the comparison is nonzero returns it,
2072 * otherwise the shorter one is ordered first.
2075 compare(const __versa_string
& __str
) const
2077 if (this->_M_compare(__str
))
2080 const size_type __size
= this->size();
2081 const size_type __osize
= __str
.size();
2082 const size_type __len
= std::min(__size
, __osize
);
2084 int __r
= traits_type::compare(this->_M_data(), __str
.data(), __len
);
2086 __r
= this->_S_compare(__size
, __osize
);
2091 * @brief Compare substring to a string.
2092 * @param __pos Index of first character of substring.
2093 * @param __n Number of characters in substring.
2094 * @param __str String to compare against.
2095 * @return Integer < 0, 0, or > 0.
2097 * Form the substring of this string from the @a __n characters
2098 * starting at @a __pos. Returns an integer < 0 if the
2099 * substring is ordered before @a __str, 0 if their values are
2100 * equivalent, or > 0 if the substring is ordered after @a
2101 * __str. Determines the effective length rlen of the strings
2102 * to compare as the smallest of the length of the substring
2103 * and @a __str.size(). The function then compares the two
2104 * strings by calling
2105 * traits::compare(substring.data(),str.data(),rlen). If the
2106 * result of the comparison is nonzero returns it, otherwise
2107 * the shorter one is ordered first.
2110 compare(size_type __pos
, size_type __n
,
2111 const __versa_string
& __str
) const;
2114 * @brief Compare substring to a substring.
2115 * @param __pos1 Index of first character of substring.
2116 * @param __n1 Number of characters in substring.
2117 * @param __str String to compare against.
2118 * @param __pos2 Index of first character of substring of str.
2119 * @param __n2 Number of characters in substring of str.
2120 * @return Integer < 0, 0, or > 0.
2122 * Form the substring of this string from the @a __n1
2123 * characters starting at @a __pos1. Form the substring of @a
2124 * __str from the @a __n2 characters starting at @a __pos2.
2125 * Returns an integer < 0 if this substring is ordered before
2126 * the substring of @a __str, 0 if their values are equivalent,
2127 * or > 0 if this substring is ordered after the substring of
2128 * @a __str. Determines the effective length rlen of the
2129 * strings to compare as the smallest of the lengths of the
2130 * substrings. The function then compares the two strings by
2132 * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
2133 * If the result of the comparison is nonzero returns it,
2134 * otherwise the shorter one is ordered first.
2137 compare(size_type __pos1
, size_type __n1
, const __versa_string
& __str
,
2138 size_type __pos2
, size_type __n2
) const;
2141 * @brief Compare to a C string.
2142 * @param __s C string to compare against.
2143 * @return Integer < 0, 0, or > 0.
2145 * Returns an integer < 0 if this string is ordered before @a
2146 * __s, 0 if their values are equivalent, or > 0 if this string
2147 * is ordered after @a __s. Determines the effective length
2148 * rlen of the strings to compare as the smallest of size() and
2149 * the length of a string constructed from @a __s. The
2150 * function then compares the two strings by calling
2151 * traits::compare(data(),s,rlen). If the result of the
2152 * comparison is nonzero returns it, otherwise the shorter one
2156 compare(const _CharT
* __s
) const;
2158 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2159 // 5 String::compare specification questionable
2161 * @brief Compare substring to a C string.
2162 * @param __pos Index of first character of substring.
2163 * @param __n1 Number of characters in substring.
2164 * @param __s C string to compare against.
2165 * @return Integer < 0, 0, or > 0.
2167 * Form the substring of this string from the @a __n1
2168 * characters starting at @a __pos. Returns an integer < 0 if
2169 * the substring is ordered before @a __s, 0 if their values
2170 * are equivalent, or > 0 if the substring is ordered after @a
2171 * __s. Determines the effective length rlen of the strings to
2172 * compare as the smallest of the length of the substring and
2173 * the length of a string constructed from @a __s. The
2174 * function then compares the two string by calling
2175 * traits::compare(substring.data(),s,rlen). If the result of
2176 * the comparison is nonzero returns it, otherwise the shorter
2177 * one is ordered first.
2180 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
) const;
2183 * @brief Compare substring against a character array.
2184 * @param __pos Index of first character of substring.
2185 * @param __n1 Number of characters in substring.
2186 * @param __s character array to compare against.
2187 * @param __n2 Number of characters of s.
2188 * @return Integer < 0, 0, or > 0.
2190 * Form the substring of this string from the @a __n1
2191 * characters starting at @a __pos. Form a string from the
2192 * first @a __n2 characters of @a __s. Returns an integer < 0
2193 * if this substring is ordered before the string from @a __s,
2194 * 0 if their values are equivalent, or > 0 if this substring
2195 * is ordered after the string from @a __s. Determines the
2196 * effective length rlen of the strings to compare as the
2197 * smallest of the length of the substring and @a __n2. The
2198 * function then compares the two strings by calling
2199 * traits::compare(substring.data(),__s,rlen). If the result of
2200 * the comparison is nonzero returns it, otherwise the shorter
2201 * one is ordered first.
2203 * NB: __s must have at least n2 characters, <em>\\0</em> has no special
2207 compare(size_type __pos
, size_type __n1
, const _CharT
* __s
,
2208 size_type __n2
) const;
2213 * @brief Concatenate two strings.
2214 * @param __lhs First string.
2215 * @param __rhs Last string.
2216 * @return New string with value of @a __lhs followed by @a __rhs.
2218 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2219 template <typename
, typename
, typename
> class _Base
>
2220 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2221 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2222 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2225 * @brief Concatenate C string and string.
2226 * @param __lhs First string.
2227 * @param __rhs Last string.
2228 * @return New string with value of @a __lhs followed by @a __rhs.
2230 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2231 template <typename
, typename
, typename
> class _Base
>
2232 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2233 operator+(const _CharT
* __lhs
,
2234 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2237 * @brief Concatenate character and string.
2238 * @param __lhs First string.
2239 * @param __rhs Last string.
2240 * @return New string with @a __lhs followed by @a __rhs.
2242 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2243 template <typename
, typename
, typename
> class _Base
>
2244 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2245 operator+(_CharT __lhs
,
2246 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
);
2249 * @brief Concatenate string and C string.
2250 * @param __lhs First string.
2251 * @param __rhs Last string.
2252 * @return New string with @a __lhs followed by @a __rhs.
2254 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2255 template <typename
, typename
, typename
> class _Base
>
2256 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2257 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2258 const _CharT
* __rhs
);
2261 * @brief Concatenate string and character.
2262 * @param __lhs First string.
2263 * @param __rhs Last string.
2264 * @return New string with @a __lhs followed by @a __rhs.
2266 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2267 template <typename
, typename
, typename
> class _Base
>
2268 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2269 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2272 #if __cplusplus >= 201103L
2273 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2274 template <typename
, typename
, typename
> class _Base
>
2275 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2276 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2277 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2278 { return std::move(__lhs
.append(__rhs
)); }
2280 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2281 template <typename
, typename
, typename
> class _Base
>
2282 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2283 operator+(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2284 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2285 { return std::move(__rhs
.insert(0, __lhs
)); }
2287 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2288 template <typename
, typename
, typename
> class _Base
>
2289 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2290 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2291 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2293 const auto __size
= __lhs
.size() + __rhs
.size();
2294 const bool __cond
= (__size
> __lhs
.capacity()
2295 && __size
<= __rhs
.capacity());
2296 return __cond
? std::move(__rhs
.insert(0, __lhs
))
2297 : std::move(__lhs
.append(__rhs
));
2300 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2301 template <typename
, typename
, typename
> class _Base
>
2302 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2303 operator+(const _CharT
* __lhs
,
2304 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2305 { return std::move(__rhs
.insert(0, __lhs
)); }
2307 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2308 template <typename
, typename
, typename
> class _Base
>
2309 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2310 operator+(_CharT __lhs
,
2311 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __rhs
)
2312 { return std::move(__rhs
.insert(0, 1, __lhs
)); }
2314 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2315 template <typename
, typename
, typename
> class _Base
>
2316 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2317 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2318 const _CharT
* __rhs
)
2319 { return std::move(__lhs
.append(__rhs
)); }
2321 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2322 template <typename
, typename
, typename
> class _Base
>
2323 inline __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>
2324 operator+(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>&& __lhs
,
2326 { return std::move(__lhs
.append(1, __rhs
)); }
2331 * @brief Test equivalence of two strings.
2332 * @param __lhs First string.
2333 * @param __rhs Second string.
2334 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2336 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2337 template <typename
, typename
, typename
> class _Base
>
2339 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2340 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2341 { return __lhs
.compare(__rhs
) == 0; }
2343 template<typename _CharT
,
2344 template <typename
, typename
, typename
> class _Base
>
2345 inline typename __enable_if
<std::__is_char
<_CharT
>::__value
, bool>::__type
2346 operator==(const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2347 std::allocator
<_CharT
>, _Base
>& __lhs
,
2348 const __versa_string
<_CharT
, std::char_traits
<_CharT
>,
2349 std::allocator
<_CharT
>, _Base
>& __rhs
)
2350 { return (__lhs
.size() == __rhs
.size()
2351 && !std::char_traits
<_CharT
>::compare(__lhs
.data(), __rhs
.data(),
2355 * @brief Test equivalence of C string and string.
2356 * @param __lhs C string.
2357 * @param __rhs String.
2358 * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise.
2360 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2361 template <typename
, typename
, typename
> class _Base
>
2363 operator==(const _CharT
* __lhs
,
2364 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2365 { return __rhs
.compare(__lhs
) == 0; }
2368 * @brief Test equivalence of string and C string.
2369 * @param __lhs String.
2370 * @param __rhs C string.
2371 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
2373 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2374 template <typename
, typename
, typename
> class _Base
>
2376 operator==(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2377 const _CharT
* __rhs
)
2378 { return __lhs
.compare(__rhs
) == 0; }
2382 * @brief Test difference of two strings.
2383 * @param __lhs First string.
2384 * @param __rhs Second string.
2385 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2387 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2388 template <typename
, typename
, typename
> class _Base
>
2390 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2391 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2392 { return !(__lhs
== __rhs
); }
2395 * @brief Test difference of C string and string.
2396 * @param __lhs C string.
2397 * @param __rhs String.
2398 * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise.
2400 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2401 template <typename
, typename
, typename
> class _Base
>
2403 operator!=(const _CharT
* __lhs
,
2404 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2405 { return !(__lhs
== __rhs
); }
2408 * @brief Test difference of string and C string.
2409 * @param __lhs String.
2410 * @param __rhs C string.
2411 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
2413 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2414 template <typename
, typename
, typename
> class _Base
>
2416 operator!=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2417 const _CharT
* __rhs
)
2418 { return !(__lhs
== __rhs
); }
2422 * @brief Test if string precedes string.
2423 * @param __lhs First string.
2424 * @param __rhs Second string.
2425 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2427 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2428 template <typename
, typename
, typename
> class _Base
>
2430 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2431 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2432 { return __lhs
.compare(__rhs
) < 0; }
2435 * @brief Test if string precedes C string.
2436 * @param __lhs String.
2437 * @param __rhs C string.
2438 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2440 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2441 template <typename
, typename
, typename
> class _Base
>
2443 operator<(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2444 const _CharT
* __rhs
)
2445 { return __lhs
.compare(__rhs
) < 0; }
2448 * @brief Test if C string precedes string.
2449 * @param __lhs C string.
2450 * @param __rhs String.
2451 * @return True if @a __lhs precedes @a __rhs. False otherwise.
2453 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2454 template <typename
, typename
, typename
> class _Base
>
2456 operator<(const _CharT
* __lhs
,
2457 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2458 { return __rhs
.compare(__lhs
) > 0; }
2462 * @brief Test if string follows string.
2463 * @param __lhs First string.
2464 * @param __rhs Second string.
2465 * @return True if @a __lhs follows @a __rhs. False otherwise.
2467 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2468 template <typename
, typename
, typename
> class _Base
>
2470 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2471 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2472 { return __lhs
.compare(__rhs
) > 0; }
2475 * @brief Test if string follows C string.
2476 * @param __lhs String.
2477 * @param __rhs C string.
2478 * @return True if @a __lhs follows @a __rhs. False otherwise.
2480 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2481 template <typename
, typename
, typename
> class _Base
>
2483 operator>(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2484 const _CharT
* __rhs
)
2485 { return __lhs
.compare(__rhs
) > 0; }
2488 * @brief Test if C string follows string.
2489 * @param __lhs C string.
2490 * @param __rhs String.
2491 * @return True if @a __lhs follows @a __rhs. False otherwise.
2493 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2494 template <typename
, typename
, typename
> class _Base
>
2496 operator>(const _CharT
* __lhs
,
2497 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2498 { return __rhs
.compare(__lhs
) < 0; }
2502 * @brief Test if string doesn't follow string.
2503 * @param __lhs First string.
2504 * @param __rhs Second string.
2505 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2507 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2508 template <typename
, typename
, typename
> class _Base
>
2510 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2511 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2512 { return __lhs
.compare(__rhs
) <= 0; }
2515 * @brief Test if string doesn't follow C string.
2516 * @param __lhs String.
2517 * @param __rhs C string.
2518 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2520 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2521 template <typename
, typename
, typename
> class _Base
>
2523 operator<=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2524 const _CharT
* __rhs
)
2525 { return __lhs
.compare(__rhs
) <= 0; }
2528 * @brief Test if C string doesn't follow string.
2529 * @param __lhs C string.
2530 * @param __rhs String.
2531 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
2533 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2534 template <typename
, typename
, typename
> class _Base
>
2536 operator<=(const _CharT
* __lhs
,
2537 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2538 { return __rhs
.compare(__lhs
) >= 0; }
2542 * @brief Test if string doesn't precede string.
2543 * @param __lhs First string.
2544 * @param __rhs Second string.
2545 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2547 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2548 template <typename
, typename
, typename
> class _Base
>
2550 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2551 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2552 { return __lhs
.compare(__rhs
) >= 0; }
2555 * @brief Test if string doesn't precede C string.
2556 * @param __lhs String.
2557 * @param __rhs C string.
2558 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2560 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2561 template <typename
, typename
, typename
> class _Base
>
2563 operator>=(const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2564 const _CharT
* __rhs
)
2565 { return __lhs
.compare(__rhs
) >= 0; }
2568 * @brief Test if C string doesn't precede string.
2569 * @param __lhs C string.
2570 * @param __rhs String.
2571 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
2573 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2574 template <typename
, typename
, typename
> class _Base
>
2576 operator>=(const _CharT
* __lhs
,
2577 const __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2578 { return __rhs
.compare(__lhs
) <= 0; }
2581 * @brief Swap contents of two strings.
2582 * @param __lhs First string.
2583 * @param __rhs Second string.
2585 * Exchanges the contents of @a __lhs and @a __rhs in constant time.
2587 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2588 template <typename
, typename
, typename
> class _Base
>
2590 swap(__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __lhs
,
2591 __versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __rhs
)
2592 { __lhs
.swap(__rhs
); }
2594 _GLIBCXX_END_NAMESPACE_VERSION
2597 namespace std
_GLIBCXX_VISIBILITY(default)
2599 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2602 * @brief Read stream into a string.
2603 * @param __is Input stream.
2604 * @param __str Buffer to store into.
2605 * @return Reference to the input stream.
2607 * Stores characters from @a __is into @a __str until whitespace is
2608 * found, the end of the stream is encountered, or str.max_size()
2609 * is reached. If is.width() is non-zero, that is the limit on the
2610 * number of characters stored into @a __str. Any previous
2611 * contents of @a __str are erased.
2613 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2614 template <typename
, typename
, typename
> class _Base
>
2615 basic_istream
<_CharT
, _Traits
>&
2616 operator>>(basic_istream
<_CharT
, _Traits
>& __is
,
2617 __gnu_cxx::__versa_string
<_CharT
, _Traits
,
2618 _Alloc
, _Base
>& __str
);
2621 * @brief Write string to a stream.
2622 * @param __os Output stream.
2623 * @param __str String to write out.
2624 * @return Reference to the output stream.
2626 * Output characters of @a __str into os following the same rules as for
2627 * writing a C string.
2629 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2630 template <typename
, typename
, typename
> class _Base
>
2631 inline basic_ostream
<_CharT
, _Traits
>&
2632 operator<<(basic_ostream
<_CharT
, _Traits
>& __os
,
2633 const __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
,
2636 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2637 // 586. string inserter not a formatted function
2638 return __ostream_insert(__os
, __str
.data(), __str
.size());
2642 * @brief Read a line from stream into a string.
2643 * @param __is Input stream.
2644 * @param __str Buffer to store into.
2645 * @param __delim Character marking end of line.
2646 * @return Reference to the input stream.
2648 * Stores characters from @a __is into @a __str until @a __delim is
2649 * found, the end of the stream is encountered, or str.max_size()
2650 * is reached. If is.width() is non-zero, that is the limit on the
2651 * number of characters stored into @a __str. Any previous
2652 * contents of @a __str are erased. If @a delim was encountered,
2653 * it is extracted but not stored into @a __str.
2655 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2656 template <typename
, typename
, typename
> class _Base
>
2657 basic_istream
<_CharT
, _Traits
>&
2658 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2659 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
,
2663 * @brief Read a line from stream into a string.
2664 * @param __is Input stream.
2665 * @param __str Buffer to store into.
2666 * @return Reference to the input stream.
2668 * Stores characters from is into @a __str until '\n' is
2669 * found, the end of the stream is encountered, or str.max_size()
2670 * is reached. If is.width() is non-zero, that is the limit on the
2671 * number of characters stored into @a __str. Any previous
2672 * contents of @a __str are erased. If end of line was
2673 * encountered, it is extracted but not stored into @a __str.
2675 template<typename _CharT
, typename _Traits
, typename _Alloc
,
2676 template <typename
, typename
, typename
> class _Base
>
2677 inline basic_istream
<_CharT
, _Traits
>&
2678 getline(basic_istream
<_CharT
, _Traits
>& __is
,
2679 __gnu_cxx::__versa_string
<_CharT
, _Traits
, _Alloc
, _Base
>& __str
)
2680 { return getline(__is
, __str
, __is
.widen('\n')); }
2682 _GLIBCXX_END_NAMESPACE_VERSION
2685 #if __cplusplus >= 201103L
2687 #include <ext/string_conversions.h>
2689 namespace __gnu_cxx
_GLIBCXX_VISIBILITY(default)
2691 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2693 #if _GLIBCXX_USE_C99_STDLIB
2694 // 21.4 Numeric Conversions [string.conversions].
2696 stoi(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2697 { return __gnu_cxx::__stoa
<long, int>(&std::strtol
, "stoi", __str
.c_str(),
2701 stol(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2702 { return __gnu_cxx::__stoa(&std::strtol
, "stol", __str
.c_str(),
2705 inline unsigned long
2706 stoul(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2707 { return __gnu_cxx::__stoa(&std::strtoul
, "stoul", __str
.c_str(),
2711 stoll(const __vstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2712 { return __gnu_cxx::__stoa(&std::strtoll
, "stoll", __str
.c_str(),
2715 inline unsigned long long
2716 stoull(const __vstring
& __str
, std::size_t* __idx
, int __base
= 10)
2717 { return __gnu_cxx::__stoa(&std::strtoull
, "stoull", __str
.c_str(),
2720 // NB: strtof vs strtod.
2722 stof(const __vstring
& __str
, std::size_t* __idx
= 0)
2723 { return __gnu_cxx::__stoa(&std::strtof
, "stof", __str
.c_str(), __idx
); }
2726 stod(const __vstring
& __str
, std::size_t* __idx
= 0)
2727 { return __gnu_cxx::__stoa(&std::strtod
, "stod", __str
.c_str(), __idx
); }
2730 stold(const __vstring
& __str
, std::size_t* __idx
= 0)
2731 { return __gnu_cxx::__stoa(&std::strtold
, "stold", __str
.c_str(), __idx
); }
2732 #endif // _GLIBCXX_USE_C99_STDLIB
2734 #if _GLIBCXX_USE_C99_STDIO
2735 // NB: (v)snprintf vs sprintf.
2739 to_string(int __val
)
2740 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, 4 * sizeof(int),
2744 to_string(unsigned __val
)
2745 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2746 4 * sizeof(unsigned),
2750 to_string(long __val
)
2751 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2756 to_string(unsigned long __val
)
2757 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2758 4 * sizeof(unsigned long),
2763 to_string(long long __val
)
2764 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2765 4 * sizeof(long long),
2769 to_string(unsigned long long __val
)
2770 { return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
,
2771 4 * sizeof(unsigned long long),
2775 to_string(float __val
)
2777 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2778 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2783 to_string(double __val
)
2785 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2786 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2791 to_string(long double __val
)
2793 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2794 return __gnu_cxx::__to_xstring
<__vstring
>(&std::vsnprintf
, __n
,
2797 #endif // _GLIBCXX_USE_C99_STDIO
2799 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
2801 stoi(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2802 { return __gnu_cxx::__stoa
<long, int>(&std::wcstol
, "stoi", __str
.c_str(),
2806 stol(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2807 { return __gnu_cxx::__stoa(&std::wcstol
, "stol", __str
.c_str(),
2810 inline unsigned long
2811 stoul(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2812 { return __gnu_cxx::__stoa(&std::wcstoul
, "stoul", __str
.c_str(),
2816 stoll(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2817 { return __gnu_cxx::__stoa(&std::wcstoll
, "stoll", __str
.c_str(),
2820 inline unsigned long long
2821 stoull(const __wvstring
& __str
, std::size_t* __idx
= 0, int __base
= 10)
2822 { return __gnu_cxx::__stoa(&std::wcstoull
, "stoull", __str
.c_str(),
2825 // NB: wcstof vs wcstod.
2827 stof(const __wvstring
& __str
, std::size_t* __idx
= 0)
2828 { return __gnu_cxx::__stoa(&std::wcstof
, "stof", __str
.c_str(), __idx
); }
2831 stod(const __wvstring
& __str
, std::size_t* __idx
= 0)
2832 { return __gnu_cxx::__stoa(&std::wcstod
, "stod", __str
.c_str(), __idx
); }
2835 stold(const __wvstring
& __str
, std::size_t* __idx
= 0)
2836 { return __gnu_cxx::__stoa(&std::wcstold
, "stold", __str
.c_str(), __idx
); }
2838 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2841 to_wstring(int __val
)
2842 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2847 to_wstring(unsigned __val
)
2848 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2849 4 * sizeof(unsigned),
2853 to_wstring(long __val
)
2854 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2859 to_wstring(unsigned long __val
)
2860 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2861 4 * sizeof(unsigned long),
2865 to_wstring(long long __val
)
2866 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2867 4 * sizeof(long long),
2871 to_wstring(unsigned long long __val
)
2872 { return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
,
2873 4 * sizeof(unsigned long long),
2877 to_wstring(float __val
)
2879 const int __n
= __numeric_traits
<float>::__max_exponent10
+ 20;
2880 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2885 to_wstring(double __val
)
2887 const int __n
= __numeric_traits
<double>::__max_exponent10
+ 20;
2888 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2893 to_wstring(long double __val
)
2895 const int __n
= __numeric_traits
<long double>::__max_exponent10
+ 20;
2896 return __gnu_cxx::__to_xstring
<__wvstring
>(&std::vswprintf
, __n
,
2899 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
2900 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
2902 _GLIBCXX_END_NAMESPACE_VERSION
2907 #if __cplusplus >= 201103L
2909 #include <bits/functional_hash.h>
2911 namespace std
_GLIBCXX_VISIBILITY(default)
2913 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2915 /// std::hash specialization for __vstring.
2917 struct hash
<__gnu_cxx::__vstring
>
2918 : public __hash_base
<size_t, __gnu_cxx::__vstring
>
2921 operator()(const __gnu_cxx::__vstring
& __s
) const noexcept
2922 { return std::_Hash_impl::hash(__s
.data(), __s
.length()); }
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)); }
2936 /// std::hash specialization for __u16vstring.
2938 struct hash
<__gnu_cxx::__u16vstring
>
2939 : public __hash_base
<size_t, __gnu_cxx::__u16vstring
>
2942 operator()(const __gnu_cxx::__u16vstring
& __s
) const noexcept
2943 { return std::_Hash_impl::hash(__s
.data(),
2944 __s
.length() * sizeof(char16_t
)); }
2947 /// std::hash specialization for __u32vstring.
2949 struct hash
<__gnu_cxx::__u32vstring
>
2950 : public __hash_base
<size_t, __gnu_cxx::__u32vstring
>
2953 operator()(const __gnu_cxx::__u32vstring
& __s
) const noexcept
2954 { return std::_Hash_impl::hash(__s
.data(),
2955 __s
.length() * sizeof(char32_t
)); }
2958 _GLIBCXX_END_NAMESPACE_VERSION
2963 #include <ext/vstring.tcc>
2965 #endif /* _VSTRING_H */