Boost logo

Boost :

Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-10-15 18:20:42


On 14 October 2011 05:32, Dave Abrahams <dave_at_[hidden]> wrote:
> Use-cases, please!

I worked on a messaging system that created messages via serialization
(that took iterators) and delivered them via UDP. Most messages were
small (<100 bytes) with occasional messages 1K-2K in size. To give
ourselves breathing room, we allowed messages up to, say, 32K, as it
would be a non-trivial effort to implement splitting/reassembly of
messages.

> How could it ever be a "drop-in replacement for vector"

For over a decade, the mental model for calling push_back, insert,
resize, etc. is that it they have no preconditions to check. This is
true *for every standard container* (which supports the corresponding
operation, of course). You want to *silently* break that consistency.
 That will lead to buffer overrun bugs, which we know are hard to
debug and

I'm not saying we don't need the unchecked functionality. I'm saying
it should never be spelled p-u-s-h-_-b-a-c-k, i-n-s-e-r-t,
r-e-s-i-z-e, etc. (which is one of the reasons I'm arguing against
making it policy based). I'm strongly opposed to any solution that
uses the same function signatures as the standard containers that
isn't as safe and easy to call as the ones in the standard containers.

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

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