basic_string<>::_M_mutate

Ryszard Kabatek rysio@rumcajs.chemie.uni-halle.de
Mon Jul 12 03:47:00 GMT 1999


On Fri, 9 Jul 1999, Benjamin Kosnik wrote:

> 
> > I think it is not a good idea. There are only three functions, that
> > return an iterator:
> >       iterator insert(iterator __p, _CharT __c = _CharT());
> >       iterator erase(iterator __position);
> >       iterator erase(iterator __first, iterator __last);
> 
> 
> This is specifically for these member functions. If you have a better 
> solution, one that can pass 21_strings/invariants.cc, post a patch and 
> I'll take a look at it.

I did following:

- in _M_mutate I added _M_rep()->_M_state = 0 again,
- only in the three above functions I added
  _M_rep()->_M_state = -1 bevore return. 

Thats all. Only in the three cases we modify the value of _M_state again.
In the most cases we do not need it. This solution has this advantage,
that we can remove the unsharability in the most of the non-const functions.

The attachment contains the patch.

1999-07-12  Ryszard Kabatek <kabatek@chemie.uni-halle.de>

        * bits/string.tcc: _M_mutate - clear _M_state again.
	* bits/basic_string.h: In the three functions that return
	  an iterator set _M_state to -1 bevore return.


Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2466 Fax. +49 3461 46 2129


More information about the Libstdc++ mailing list