|
Boost : |
Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-10-12 13:30:48
> > I'm presently against any throwing behavior related to resizing of a
> > StaticVector/static_vector, since one can usually easily check the relevant
> > preconditions themselves. Just assert. For those who want defined
> > behavior
> >
> It's not always you know that you're dealing with a static_vector, but just
> some code that expects push_back() to work or throw.
Consider a generic algorithm that takes a "push_back-able" type and inserts
elements into it using push_back(), and expects the push_back() to work to throw.
When you invoke this algorithm, you either know in advance how
many elements it will add, or you don't.
If you do, then when calling this algorithm *with a static_vector*, you need
to check beforehand whether there is enough space in the static_vector.
I think that's a reasonable requirement, given that you know, at the call site,
that you're dealing with a static_vector.
If you don't, then calling the algorithm with a static_vector is a conceptual
error in the first place, because you are passing a container with a fixed
capacity to an algorithm that expects to be able to add a variable number
of elements to it.
Regards,
Nate
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk