Boost logo

Boost Users :

Subject: Re: [Boost-users] boost optional assignment
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-08-17 17:10:45


On Fri, Aug 17, 2012 at 4:35 AM, tolik levchik <endight_at_[hidden]> wrote:
> The following code gives me compilation error. With const reference it's ok.
> Is it right behaviour?

Tolik,

I've never tried to pass a mutable reference into an object's copy
constructor (and furthermore I cannot imagine a reason to).

Nevertheless, on my machine (boost 1.48, gcc 4.5.3) this works:

  // opt = *ptr; // error
  opt.reset(*ptr); // good

I'm not sure why one works while the other doesn't as they both appear
to be declared the same:

    optional& operator= ( argument_type val )
      {
        this->assign( val ) ;
        return *this ;
      }

  void reset ( argument_type val ) { assign(val); }

Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net