patch: please add string::erase()'s

Yotam Medini yotamm@tmai.com
Thu Oct 9 16:52:00 GMT 1997


>   References: <199710071722.KAA29380.cygnus.egcs@telaviv.tmai.com>
>   From: Jason Merrill <jason@cygnus.com>
>   Date: 07 Oct 1997 11:32:56 -0700
>
>   >>>>> Yotam Medini <yotamm@tmai.com> writes:
>
>   > How about adding the following standard members 
>   > to basic_string in bastring.h.
>
>   How about sending me a patch?
>
>   Jason

Ok, here it is. It seemed to work with a small program I tried.
Please educate me if there is a better or more conventional way
to produce a patch.
thanks -- yotam
------------------------------------------------------------------------
telaviv:877> ls -l bastring.h ~/C/egcs/bastring.h 
-rw-r--r--   1 yotamm   products    19683 Oct  9 15:53 /home/yotamm/C/egcs/bastring.h
-rw-r--r--   1 yotamm   products    18994 Sep 11 18:56 bastring.h
telaviv:878> diff -c bastring.h ~/C/egcs/bastring.h 
*** bastring.h	Thu Sep 11 18:56:59 1997
--- /home/yotamm/C/egcs/bastring.h	Thu Oct  9 15:53:32 1997
***************
*** 230,240 ****
      { size_type pos = p - begin(); insert (pos, first, last - first); }
  #endif
  
!   basic_string& remove (size_type pos = 0, size_type n = npos)
      { return replace (pos, n, (size_type)0, (charT)0); }
!   basic_string& remove (iterator pos)
      { return replace (pos - begin (), 1, (size_type)0, (charT)0); }
!   basic_string& remove (iterator first, iterator last)
      { return replace (first - begin (), last - first, (size_type)0, (charT)0);}
  
    basic_string& replace (size_type pos1, size_type n1, const basic_string& str,
--- 230,262 ----
      { size_type pos = p - begin(); insert (pos, first, last - first); }
  #endif
  
!   iterator erase(iterator first, iterator last)
!     { 
!        size_type pos = first - begin (); 
!        replace (pos, last - first, (size_type)0, (charT)0); 
!        return pos +begin ();
!     }
!   iterator erase(iterator p)
!     { 
!        size_type pos = p - begin (); 
!        replace (pos, 1, (size_type)0, (charT)0); 
!        return pos +begin ();
!     }
!   basic_string& erase(size_type pos = 0, size_type n = npos)
!     {
!        size_type len = length();
!        size_type posLen = len - pos;
!        if (n > posLen)
!          n = posLen;
!        replace (pos, n, (size_type)0, (charT)0); 
!        return *this;
!     }
! 
!   basic_string& remove (size_type pos = 0, size_type n = npos) /*Deprecated*/
      { return replace (pos, n, (size_type)0, (charT)0); }
!   basic_string& remove (iterator pos)                          /*Deprecated*/
      { return replace (pos - begin (), 1, (size_type)0, (charT)0); }
!   basic_string& remove (iterator first, iterator last)         /*Deprecated*/
      { return replace (first - begin (), last - first, (size_type)0, (charT)0);}
  
    basic_string& replace (size_type pos1, size_type n1, const basic_string& str,



More information about the Gcc mailing list