|
Boost : |
From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2004-09-17 11:56:28
Peter Dimov wrote:
> Fernando Cacciola wrote:
>> "David Abrahams" <dave_at_[hidden]> escribió en el mensaje
>> news:uvfee6kpk.fsf_at_boost-consulting.com...
>>>
>>> I'm finding the documentation for in-place factories highly
>>> frustrating. There's no formal documentation for
>>> TypedInPlaceFactory, and almost no description whatsoever for
>>> InPlaceFactory. None of what's there describes how these things
>>> interact with optional; it isn't even mentioned in the corresponding
>>> section!
>>>
>> That stuff started out almost as an experiment and was intended to be
>> generally usefull for all sorts of container classes. [...]
>
>> From the documentation:
>
> "For example, one member of this familiy looks like:
>
> template<class T,class A0, class A1>
> class TypedInPlaceFactory2
> {
> A0 m_a0 ; A1 m_a1 ;
>
> public:
>
> TypedInPlaceFactory2( A0 const& a0, A1 const& a1 ) : m_a0(a0),
> m_a1(a1) {}
>
> void construct ( void* p ) { new (p) T(m_a0,m_a1) ; }
> } ;
>
> A wrapper class aware of this can use it as:
>
> class W
> {
> X wrapped_ ;
>
> public:
>
> W ( X const& x ) : wrapped_(x) {}
> W ( TypedInPlaceFactory2 const& fac ) { fac.construct(&wrapped_) ; }
> } ;"
>
> This doesn't look correct to me. W::wrapped_ is default constructed
> and then another X is placement-constructed on top of it.
>
Wrong indeed.
Fernando Cacciola
SciSoft
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk