basic_string<>::reserve - patch

Ryszard Kabatek rysio@rumcajs.chemie.uni-halle.de
Thu Dec 30 07:30:00 GMT 1999


As suggested by Nathan Myers I modified the _M_clone member function.
I added a second parameter:
       _CharT*
       _M_clone(const _Alloc&, size_type __res = 0);

Now it can be used in basic_string<>::reserve too. 

In reserve I added a check for _M_state too. Otherwise it would not have
the expected behaviour if the string has enough storage reserved but
it has reference copies.

BTW. In reserve we not check the __res_arg vlaue for a length_error.
     If max_size() is much less than npos we should.
     But I do not know if the standard allows reserve to throw
     a length_error. If not it means that max_size() must return a value
     very close to npos.


The attachment contains the patch.

1999-06-30  Ryszard Kabatek <kabatek@chemie.uni-halle.de>

         * bits/basic_string.h: Add a size_type parameter to _M_clone
           with a default value set to 0.
         * bits/string.tcc: In _M_clone by the call of _S_create
	   add the value of the new parameter to _M_length.
           In reserve check _M_state and use _M_clone instead of _M_mutate.


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


More information about the Libstdc++ mailing list