Boost logo

Boost :

Subject: Re: [boost] Stack-based vector container
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-01-23 02:05:56


On Sat, Jan 22, 2011 at 8:11 PM, Stephan T. Lavavej
<stl_at_[hidden]> wrote:
> [Emil Dotchevski]
>> std::vector is allowed to be stack-based when possible.
>
> STL containers must support O(1), nofail, non-iterator-invalidating swaps*.  According to my understanding, this forbids a "Small Vector Optimization", if not in theory then in practice (i.e. without compromising performance elsewhere).

You're STL after all :) so please correct me if I'm wrong, but
according to my understanding the compiler is allowed to "know" the
specific semantics of standard functions and classes, and optimize
based on that knowledge. In this case, if the compiler can prove that
swap isn't called for that vector, there is no problem. I don't think
that the compiler is even required to parse any standard headers such
as <vector>, it just has to make available (implement) the semantics
of the types and the definitions they contain as specified by the
standard.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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