Boost logo

Boost :

Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-10-14 17:07:33


Christian Holmquist wrote:
> On 14 October 2011 12:55, Dave Abrahams <dave_at_[hidden]> wrote:
> > Is throwing an exception going to turn an incorrect program into a
> > correct one?
>
> I'm probably completely misunderstanding your point of view, or rather,
> what is your point of view?

He's saying that if a program does a push_back when the capacity has been
reached, this program has a logic error, and throwing an exception will not
make the error go away.

I'm not so sure of that, because doing a push_back when the capacity has
been reached is not necessarily a logic error if the code is well aware of
the possibility and prepared to handle the exception.

try
{
    do some push_backs into a static_vector; we don't know how many
}
catch( out_of_capacity& )
{
    // ignore, what we gathered so far is good enough for gov't use
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk