Ticket #1910: function_assignment.patch

File function_assignment.patch, 1.1 KB (added by niels_dekker, 14 years ago)

boost::function assignment operators calling move_assign. (Update: the patch now has a by-value argument for the copy assignment operator.)

  • function_template.hpp

     
    786786      else vtable = 0;
    787787    }
    788788
     789protected:
    789790    // Moves the value from the specified argument to *this. If the argument
    790791    // has its function object allocated on the heap, move_assign will pass
    791792    // its buffer to *this, and set the argument's buffer pointer to NULL.
     
    913914
    914915  function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
    915916
    916   self_type& operator=(const self_type& f)
     917  self_type& operator=(self_type f)
    917918  {
    918     self_type(f).swap(*this);
     919    this->move_assign(f);
    919920    return *this;
    920921  }
    921922
     
    930931#endif
    931932  operator=(Functor f)
    932933  {
    933     self_type(f).swap(*this);
     934    self_type temp(f);
     935    this->move_assign(temp);
    934936    return *this;
    935937  }
    936938
     
    944946
    945947  self_type& operator=(const base_type& f)
    946948  {
    947     self_type(f).swap(*this);
     949    self_type temp(f);
     950    this->move_assign(temp);
    948951    return *this;
    949952  }
    950953};