Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2003-10-01 21:42:52


"David Abrahams" <dave_at_[hidden]> escribió en el mensaje news:usmmfz2yy.fsf_at_boost-consulting.com...
> Brian McNamara <lorgon_at_[hidden]> writes:
>
> > As a final aside, would that we could write
> >
> > uninitialized Foo foo; // new keyword
> > // call placement new to construct the object later
> >
> > to mean
> >
> > unsigned char bits[ sizeof(Foo) ]; // suitably aligned
> > Foo& foo = *( (Foo*)( (void*)(bits) ) ); // cast the bits
> > // call placement new to construct the object later
> >
> > in C++! I hate having to "hack at the system level" to do something
> > which can be expressed more simply at the language level.
>
> Have you seen the Boost optional library?
> Maybe we need a backdoor for placement new in that library?
>
If I understood the problem correctly, this backdoor is already supported:

optional<T> opt( in_place(a0,a1,a2) ) ; // a0,a1,a2 are arguments to a T ctor.

This support is already implemented in CVS.

Fernando Cacciola


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk