Boost logo

Boost :

Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Andrew Hundt (athundt_at_[hidden])
Date: 2011-10-13 22:56:17


On Thu, Oct 13, 2011 at 10:36 PM, Nevin Liber <nevin_at_[hidden]> wrote:
> On 13 October 2011 18:08, Andrew Hundt <athundt_at_[hidden]> wrote:
>> After comments by Nate Ridge, Dave Abrahams, and others, I have become
>> convinced that push_back should be unchecked and exceeding the bounds
>> should be undefined, with an option to turn on checking.
>
>
> While I really disagree with this (as there are both use cases for it
> and, more importantly, it is no longer a drop in replacement for
> vector because your push_back will now behave differently),

While I wish it could be a drop in replacement, I think it would be
unreasonable to throw bad_alloc, since no allocations even happen at
all. Thus, it couldn't be a truly drop in replacement anyway.

Additionally, I found that since the behavior of accessing
vector.begin()-1 is undefined, that makes an undeniably compelling
argument that the correct behavior for accessing StaticVector.end()+1
should also be undefined.

> don't just do it for push_back; do it for all the insert methods as well.

that is the plan

Cheers!
Andrew Hundt


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