
On Wed, 16 Feb 2005 12:10:01 -0300 "Fernando Cacciola" <fernando_cacciola@hotmail.com> wrote:
The correct fix along Joe's initial proposal would be:
void assign(optional_base const& rhs) { if (is_initialized) { if ( rhs.is_initialized ) get_impl() = rhs.get_impl(); else destroy(); } else { if ( rhs.is_initialized ) construct(rhs.get_impl()); } }
AFAICS, this code is as safe aliasing-wise as it can be (it handles not only the trivial case of this==&rhs but also any other deeper aliasing issues)
If no voice is raised I'll proceed with this fix.
Unfortunately, I believe you now have a new dependency on copy-assignment (i.e., T::operator=()), which IIRC, did not previously exist. This may break existing code for users whose classes do not implement copy assignment.