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
> [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
Reverge Studios, Inc.