Boost logo

Boost :

From: Joe Gottman (jgottman_at_[hidden])
Date: 2006-02-01 20:11:11

"Joe Gottman" <jgottman_at_[hidden]> wrote in message
> There is an error in the implementation of the converting assignment
> operator for optional<T>. It is currently implemented as
> template<class U>
> optional& operator= ( optional<U> const& rhs )
> {
> this->assign(rhs.get());
> return *this ;
> }
> The problem with this is that if rhs is not initialized then rhs.get()
> asserts.

   I posted this bug report about a month ago. With the new version of
boost coming out, I think that it should be fixed in time for boost 1.34.
It seems to me that this is a fairly simple fix:

template <class U>
optional& operator=(optional<U> const &rhs)
    if (rhs.is_initialized()) {
   } else if (this->is_initialized()) {
    return *this;

Joe Gottman

Boost list run by bdawes at, gregod at, cpdaniel at, john at