|
Boost : |
From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-11-01 11:49:29
Hi
I've uploaded a new version of the library in the vault: *
http://tinyurl.com/2og6st*
It now provides also a new class (poly<T>) that maintains the never-empty
guarantee.
poly<T> and optional_poly<T> share a large part of their implementation, so
I think it is sound to have both in the same library.
On 10/22/07, Steven Watanabe <steven_at_[hidden]> wrote:
>
> When I was trying to do this I only used the small
> object optimization for types that I knew to have a no-throw
> copy constructor (i.e. builtin types at the moment). In C++Ox
> this can be loosened to having a no-throw move constructor.
>
My solution is more aggressive, allowing more optimization opportunities.
Basically, if an object is small, it will be always stored in the small
buffer when the poly is constructed.
It will be allocated on heap only when the guarantee is at stake, e.g.
during a swap between types that both lack a no-throw copy (it is sufficient
that one of them have the no throw copy to avoid this allocation).
Assignment operator is implemented by means of swap, so the same applies to
it.
I would like to take advantage also of movable types in the implementation
of swap, so I'd like to see a move library submitted to boost.
Corrado
-- __________________________________________________________________________ dott. Corrado Zoccolo mailto:zoccolo_at_[hidden] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk