From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2005-02-16 14:25:46


On Wed, 16 Feb 2005 12:10:01 -0300
"Fernando Cacciola" <fernando_cacciola_at_[hidden]> 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.