|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2003-02-25 20:28:12
"David Abrahams" <dave_at_[hidden]> escribió en el mensaje
news:uheatguzv.fsf_at_boost-consulting.com...
> "Fernando Cacciola" <fernando_cacciola_at_[hidden]> writes:
>
> > I thougth about placement new as a way to achieve
> > in-place optional construction, precisely because of the forwarding
> > problem, but I couldn't get it to really work.
> > What would it be like, exactly?
> >
> > I considered:
> >
> > (a)
> >
> > optional<int> opt ( new ( optional_tag ) int(1) ) ;
> >
> > this won't work because 'opt.m_storge' doesn't exist yet inside
placement
> > new.
> >
> > (b)
> >
> > optional<int> opt ;
> > new (opt) int(2);
> >
> > this would be close, but what should I do with the 'int*'
> > which is the result of the new?
>
> Why do you feel the need to do something with it? Do you do something
> with the pointer when you do placement new in the optional
> implementation?
>
No, right're right :-)
Is perfectly possible to simply discard it, though to me it looks kind of
akward in anything but deeply low-level code.
Anyway, doesn't this require a definition of placement operator new for each
T?
Fernando Cacciola
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk