Questions about the implementation of Observable& Observable::operator=(const Observable& o)

Posted by Mike Jake on
URL: http://quantlib.414.s1.nabble.com/Questions-about-the-implementation-of-Observable-Observable-operator-const-Observable-o-tp7820.html

    /*! \warning notification is sent before the copy constructor has
                 a chance of actually change the data
                 members. Therefore, observers whose update() method
                 tries to use their observables will not see the
                 updated values. It is suggested that the update()
                 method just raise a flag in order to trigger
                 a later recalculation.
    */
    inline Observable& Observable::operator=(const Observable& o) {
        // as above, the observer set is not copied. Moreover,
        // observers of this object must be notified of the change
        if (&o != this)
            notifyObservers();
        return *this;
    }


Question 1> Why the doc says that "notification is sent before the copy constructor has a chance of actually change the data      members"?

Question 2> Since the operator= doesn't modify the current object(this), why we should call notifyObservers()?

Thank you

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users