Boost logo

Boost :

From: Michael Walter (michael.walter_at_[hidden])
Date: 2006-12-30 18:09:05


Hello,

the following code fails using Boost 1.33.1, gcc version 3.4.2 (mingw-special):

  boost::optional<double> x;
  x=boost::optional<float>(boost::none); // converting assignment

with the following error message:

  Assertion failed: this->is_initialized(), file
...boost/optional/optional.hpp, line 531

Replacing

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

by e.g.

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

should fix the bug.

Regards,
Michael


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk