
The As If Rule always applies, but I can confidently say that nobody's compiler and Standard Library implementation conspires in such a way. STL ________________________________________ From: boost-bounces@lists.boost.org [boost-bounces@lists.boost.org] on behalf of Emil Dotchevski [emildotchevski@gmail.com] Sent: Saturday, January 22, 2011 11:05 PM To: boost@lists.boost.org Subject: Re: [boost] Stack-based vector container On Sat, Jan 22, 2011 at 8:11 PM, Stephan T. Lavavej <stl@exchange.microsoft.com> 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 _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost