Boost logo

Boost :

Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-10-19 01:46:53


On 16 October 2011 06:50, Dave Abrahams <dave_at_[hidden]> wrote:
>> It's still silent, as it isn't the same interface even though the
>> actual call looks the same.
>
> Well, now we could pick nits over the meaning of "same interface."

Are the "Requires" clauses in the Standard part of the interface or
not? I see the answer to that question as something fundamental, not
picking nits.

In my point of view they are part of the interface, as they describe
when it is legal for me to make a particular function call.

>> In some sense it is O(1), since N is bounded, but I know what you
>> mean. :-)
>
> There's also the nonthrowing part.

I agree. Then again, the only alternative is not providing swap at all.

> I'm not.  If you think I am, you've misconstrued me.  I'm just trying to
> understand the design space and represent a point-of-view about handling
> likely programmer errors that I think is important and overlooked.

When you mess with programmer's expectations, you get programmer errors.

> I do very much dislike the idea of having multiple interfaces for what
> is essentially the same semantics.

Of course, I'm arguing they are different interfaces, but to address
this point, we have multiple interfaces for the same semantics all the
time. c.push_back(x) is just c.insert(c.end(), x), c.clear() is just
c.erase(c.begin(), c.end()), etc. Just today I had to show someone
the swap trick for releasing space in a vector because there is no
obvious way to do it in C++03; I don't consider that a good thing.

> There are certainly applications
> where it's knowable statically that the limit can never be violated
> where one might want to drop in a bounded vector in place of
> std::vector, and having to spell push_back some other way, as though it
> were essentially different, is ugly.

I don't think we can resolve this. I see them as different
interfaces; you may not. Subtle interface differences lead to subtle
bugs.

-- 
 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