"Peter Dimov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > David Abrahams wrote: > > "Fernando Cacciola" <[EMAIL PROTECTED]> writes: > > > >> 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? > > > > I don't know, possibly so. It's been so long I've forgotten more than > > I ever knew ;-) > > It only requires > > template<class T> void * operator new(size_t n, optional<T> & t); > > I think. > > One problem is that there is no reliable way to prevent > > optional<X> opt; > new(opt) Y; // oops > > since the type being created is not communicated to operator new, only its > size is. > Yes, that's why I was thinking of something that were overloaded for T rather than for optional<T>.
Anyway, there are still problems with this: operator new is called _before_ the T is constructed, so there won't be a way, AFAICT, to properly set the initialized flag ('cause if T ctor throws, placement new won't be aware of it) -- Fernando Cacciola _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost