Re: [Boost-bugs] [Boost C++ Libraries] #3395: Assignment to optional is not possible if operator& is overriden

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3395: Assignment to optional is not possible if operator& is overriden
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-03 07:02:43


#3395: Assignment to optional is not possible if operator& is overriden
---------------------------------+------------------------------------------
 Reporter: andysem | Owner: fcacciola
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: optional
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: optional assignment |
---------------------------------+------------------------------------------

Comment(by andysem):

 BTW, I just now noticed that the assignment operator accepts its argument
 by value. It may be worth to accept it by const reference, as the operator
 is not only called for in-place factories but also for other types. For
 example:

 {{{
 struct MyString
 {
     MyString(std::string const&);
 };

 std::string str = "Hello";
 boost::optional< MyString > opt;

 opt = str; // here a needless copy of str will be constructed
 }}}

 I'm attaching an updated patch that fixes this, too.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3395#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC