
From: "Niels Dekker - mail address until 2008-12-31" <nd_mail_address_valid_until_2008-12-31@xs4all.nl> Subject: Re: [boost] [optional] problems with swap()
Thorsten Ottosen wrote: <snip>
What would you think of having boost::optional implemented by holding a pointer to T, instead of an aligned_storage object and a m_initialized flag? It would manage the memory that the pointer would point to. Having NULL would indicate being uninitialized. (I admit it's a rather theoretical question, because I don't even know if Fernando would like such an approach...)
I don't think that it is a good idea to have a pointer, I expect no extra allocation from optional. You can always try to do that in another class, optional_ptr or whatever name you want for. I think that this class will be very eassy to implement. Still I will expect value semantics, and in this case the extra allocation on copy constructors and assignations will be very inefficient. Best _____________________ Vicente Juan Botet Escriba