Boost logo

Boost :

Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Andrew Hundt (athundt_at_[hidden])
Date: 2011-10-14 11:14:11

On Fri, Oct 14, 2011 at 10:48 AM, Nevin Liber <nevin_at_[hidden]> wrote:
> 2011/10/14 Ion Gaztañaga <igaztanaga_at_[hidden]>:
> but we currently have no
>> push_back preconditions for push_back, insert, etc. and this can be a great
>> source of mistakes.
> I agree.  And unlike at() vs. operator[], in this case we are moving
> enforcement of the class invariants from the class itself the caller,
> just to save an "if" check.

That if check can be quite a difference after its called for the
billionth time in an inner loop, though you address this just below.

> I really don't want to see a policy controlling this; rather, have
> unchecked_push_back and unchecked_insert for those who need every
> ounce of performance at the expense of safety.

I definitely see a lot of clarity in implementing it this way. I just
wish there was a nicer name than unchecked_push_back.

Policies could be both a blessing and a curse. It makes it
extraordinarily easy to switch from checked to unchecked push back in
a large code base without going through everything by hand. You can
test your code with the checked policy, then turn it off to get the
performance. On the other hand, maybe you should be going through all
the code when you want to switch from checked to unchecked to make
sure there are no dependencies on that policy that would become a bug.

Boost list run by bdawes at, gregod at, cpdaniel at, john at