This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

basic_string<>::_M_mutate


        * 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]