On Wed, Sep 4, 2013 at 2:10 PM, Daniel Krügler
<[email protected]> wrote:
> I expect that this kind of index violation is a rather often occurring
> pattern and should be isolated. IMO the _M_range
> _check now pessimisms the normal, non-violating case.
Did you mean "pessimises code size", or something else?
> Why not simply
> replacing it by something along the lines of
>
> _M_range_check(size_type __n) const
> {
> if (__n >= this->size())
>
> __throw_out_of_range(__index_out_of_range_msg(__N("vector::_M_range_check"),
> __n, this->size()));
> }
>
> where __index_out_of_range_msg is a reusable function that uses
> something like snprintf_lite internally?
Some disadvantages to doing that:
1. The actual message is now "magically" transformed inside
__index_out_of_range_msg into the final message, making translation
more difficult.
2. __index_out_of_range_msg() would have to return a string, which is heavier
weight (in try#1 I just used snprintf, which was considered "too heavy").
Thanks,
--
Paul Pluzhnikov