From 0e707673d273651f3b1f75beb53c42c9d521e3c4 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 23 Jan 2004 13:57:19 +0000 Subject: [PATCH] basic_string.h (push_back(_CharT)): Call _M_replace_aux. 2004-01-23 Paolo Carlini * include/bits/basic_string.h (push_back(_CharT)): Call _M_replace_aux. (insert(size_type, const basic_string&)): Trivial tweak. (insert(size_type, size_type, _CharT)): Call _M_replace_aux. (insert(iterator, _CharT)): Ditto. (erase(size_type, size_type)): Ditto. (erase(iterator)): Ditto. (erase(iterator, iterator)): Ditto. (replace(size_type, size_type, size_type, _CharT)): Ditto. From-SVN: r76420 --- libstdc++-v3/ChangeLog | 12 +++++++++++ libstdc++-v3/include/bits/basic_string.h | 37 +++++++++++++------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d648224..c3947b3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2004-01-23 Paolo Carlini + + * include/bits/basic_string.h (push_back(_CharT)): + Call _M_replace_aux. + (insert(size_type, const basic_string&)): Trivial tweak. + (insert(size_type, size_type, _CharT)): Call _M_replace_aux. + (insert(iterator, _CharT)): Ditto. + (erase(size_type, size_type)): Ditto. + (erase(iterator)): Ditto. + (erase(iterator, iterator)): Ditto. + (replace(size_type, size_type, size_type, _CharT)): Ditto. + 2004-01-23 Loren J. Rittle libstdc++/13823 diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 56efb54..1b7cc76 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -771,7 +771,7 @@ namespace std */ void push_back(_CharT __c) - { this->replace(_M_iend(), _M_iend(), 1, __c); } + { _M_replace_aux(this->size(), size_type(0), size_type(1), __c); } /** * @brief Set value to contents of another string. @@ -895,7 +895,7 @@ namespace std */ basic_string& insert(size_type __pos1, const basic_string& __str) - { return this->insert(__pos1, __str, 0, __str.size()); } + { return this->insert(__pos1, __str, size_type(0), __str.size()); } /** * @brief Insert a substring. @@ -978,11 +978,8 @@ namespace std */ basic_string& insert(size_type __pos, size_type __n, _CharT __c) - { - const iterator __iterator = this->_M_ibegin() - + _M_check(__pos, "basic_string::insert"); - return this->replace(__iterator, __iterator, __n, __c); - } + { return _M_replace_aux(_M_check(__pos, "basic_string::insert"), + size_type(0), __n, __c); } /** * @brief Insert one character. @@ -1002,7 +999,7 @@ namespace std { _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); const size_type __pos = __p - _M_ibegin(); - this->replace(__p, __p, size_type(1), __c); + _M_replace_aux(__pos, size_type(0), size_type(1), __c); _M_rep()->_M_set_leaked(); return this->_M_ibegin() + __pos; } @@ -1042,11 +1039,8 @@ namespace std */ basic_string& erase(size_type __pos = 0, size_type __n = npos) - { - return this->replace(_M_ibegin() + _M_check(__pos, "basic_string::erase"), - _M_ibegin() + __pos + _M_limit(__pos, __n), - _M_data(), _M_data()); - } + { return _M_replace_aux(_M_check(__pos, "basic_string::erase"), + _M_limit(__pos, __n), size_type(0), _CharT()); } /** * @brief Remove one character. @@ -1064,10 +1058,10 @@ namespace std { _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin() && __position < _M_iend()); - const size_type __i = __position - _M_ibegin(); - this->replace(__position, __position + 1, _M_data(), _M_data()); + const size_type __pos = __position - _M_ibegin(); + _M_replace_aux(__pos, size_type(1), size_type(0), _CharT()); _M_rep()->_M_set_leaked(); - return _M_ibegin() + __i; + return _M_ibegin() + __pos; } /** @@ -1087,10 +1081,10 @@ namespace std { _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last && __last <= _M_iend()); - const size_type __i = __first - _M_ibegin(); - this->replace(__first, __last, _M_data(), _M_data()); + const size_type __pos = __first - _M_ibegin(); + _M_replace_aux(__pos, __last - __first, size_type(0), _CharT()); _M_rep()->_M_set_leaked(); - return _M_ibegin() + __i; + return _M_ibegin() + __pos; } /** @@ -1196,9 +1190,8 @@ namespace std */ basic_string& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) - { return this->replace(_M_ibegin() + _M_check(__pos, "basic_string::replace"), - _M_ibegin() + __pos + _M_limit(__pos, __n1), - __n2, __c); } + { return _M_replace_aux(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __n2, __c); } /** * @brief Replace range of characters with string. -- 2.7.4