This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] Money_get::do_get appends?!?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Nathan Myers <ncm-nospam at cantrip dot org>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 04 Feb 2002 00:57:20 +0100
- Subject: Re: [RFC] Money_get::do_get appends?!?
- Organization: Università della Tuscia, Viterbo, ITALY
- References: <3C5D9FBF.732203D@unitus.it> <20020203224410.B21265@cantrip.org> <3C5DBF94.6060702@unitus.it> <20020203235043.A58255@cantrip.org>
- Reply-to: pcarlini at unitus dot it
Nathan Myers wrote:
>>>Almost. If it fails, it must leave the string unchanged.
>>>
>>You mean: I can call erase at the beginning and then, if it fails during
>>the parsing, I must remember to call erase once more before bailing out???
>>
>Sorry, worse than that. If the user passes in "Golgafrincham" the user
>has to get back either "123" or "Golgafrincham". You can avoid an
>allocation by parsing characters into an array on the stack and
>expanding to secondary storage only if it's exceeded, and then copying
>into the string storage. If it helps any you can make it (or a separate
>function, for the purpose) a friend of basic_string<>::_Rep. Or you
>can use basic_string<>::swap.
>
I see. In fact I suspected that something like this was needed in such
cases.
Tomorrow, if Benjamin does not beat me, I will check the current
implementation wrt what you indicated. Definitely, we must fix it not to
always append chars on the string passed by reference.
Thanks,
Paolo.