This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Tighten length error check in string::replace
Phil Edwards wrote:
>When I cleaned up and doc'd std_bitset.h, I added some explanatory text
>to the messages in the exceptions. Previously they were all "bitset"
>which IMHO isn't very helpful to the end user.
>
>So for example, if we know that the code contains
>
> __throw_length_error("basic_string::replace -- foo, bar, baz, blah");
>
>then the testcase might be able to catch an exception and verify that
>
> ex.what() == "basic_string::replace -- foo, bar, baz, blah"
>
>This would distinguish it from all the other length_error instances.
>
Interesting. Thanks! I would like to work out something similar for
basic_string in the near future...
As regards the testcase at hand, however, it is slightly different,
since the various possible length_error exceptions already happen in
clearly distinguishable methods, that is basic_string::replace,
basic_string::_M_replace, basic_string::_S_create.
Ciao, Paolo.