|
Boost : |
Subject: Re: [boost] Stack-based vector container
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2011-01-23 02:13:49
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_at_[hidden] [boost-bounces_at_[hidden]] on behalf of Emil Dotchevski [emildotchevski_at_[hidden]]
Sent: Saturday, January 22, 2011 11:05 PM
To: boost_at_[hidden]
Subject: Re: [boost] Stack-based vector container
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
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk