Ticket #3395: optional.hpp.patch

File optional.hpp.patch, 789 bytes (added by Andrey Semashev, 13 years ago)

An updated fix that also optimises away copying the assignment argument

  • .hpp

    old new  
    2828#include "boost/detail/reference_content.hpp"
    2929#include "boost/none.hpp"
    3030#include "boost/utility/compare_pointees.hpp"
     31#include "boost/utility/addressof.hpp"
    3132
    3233#include "boost/optional/optional_fwd.hpp"
    3334
     
    525526    // Assigns from an expression. See corresponding constructor.
    526527    // Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED
    527528    template<class Expr>
    528     optional& operator= ( Expr expr )
     529    optional& operator= ( Expr const& expr )
    529530      {
    530         this->assign_expr(expr,&expr);
     531        this->assign_expr(expr,boost::addressof(expr));
    531532        return *this ;
    532533      }
    533534#endif