basic_string.h (push_back(_CharT)): Call _M_replace_aux.
authorPaolo Carlini <pcarlini@suse.de>
Fri, 23 Jan 2004 13:57:19 +0000 (13:57 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 23 Jan 2004 13:57:19 +0000 (13:57 +0000)
2004-01-23  Paolo Carlini  <pcarlini@suse.de>

* 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
libstdc++-v3/include/bits/basic_string.h

index d6482244e6dfdce270a3f0acf9b8f63bea9293b4..c3947b38d6ee6e8ffd92b1030e2a2c81d755b6b1 100644 (file)
@@ -1,3 +1,15 @@
+2004-01-23  Paolo Carlini  <pcarlini@suse.de>
+
+       * 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  <ljrittle@acm.org>
 
        libstdc++/13823
index 56efb5441cd250d2d3f64a1ac6a5a465188dec24..1b7cc764ff39c2639fbffb225f80900eb5c30a17 100644 (file)
@@ -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.