This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
basic_string<>::_M_mutate
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: basic_string<>::_M_mutate
- From: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
- Date: Fri, 9 Jul 1999 14:26:50 +0200 (CEST)
- cc: libstdc++@sourceware.cygnus.com
- Reply-To: Ryszard Kabatek <kabatek@chemie.uni-halle.de>
* bits/string.tcc (string:_M_mutate): Keep leaked value in
_M_state, which means that whenever begin() or end() has been
called, the string is unshareable, period. By doing this, insert
and erase member functions that return iterators can remain
footloose and fancy free.
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);
Any other non-const function (and there is a lot of them)
do not need such solution. This functions are a good occasion to remove
the unsharability and I think we should keep it.
It is much better to go back to the previous solution and in the three
above functions use:
replace(...);
_M_rep()->_M_state = -1; // locking not necessary; we know _M_state == 0
return _M_ibegin() + x.
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