Login  Register

Re: quantlib Handle compile error

Posted by Kakhkhor Abdijalilov on May 25, 2010; 5:56pm
URL: http://quantlib.414.s1.nabble.com/quantlib-Handle-compile-error-tp7722p7727.html

I have another question. Doesn't Handle class duplicate the
functionality of  shared_ptr? I understand, that RelinkableHandle has
a whole new capability. But what Handle class can do which shared_ptr
can't?

Consider 2 examples below. Why would one prefer Example 2 over Example
1? In my view, they are identical unless I am missing something.

Regards,
Kakhkhor Abdijalilov.


//====== Example 1 usig shared_ptr ======
class MyInstrument : public Observer {
  public:
    MyInstrument(const shared_ptr<Quote>& spot): spot_(spot) {
        registerWith(*spot_);
    }
  private:
    shared_ptr<Quote> spot_;

};

//====== Example 2 usig Handle ======
class MyInstrument : public Observer {
  public:
    MyInstrument(const Handle<Quote>& spot): spot_(spot) {
        registerWith(spot_);
    }
  private:
    Handle<Quote> spot_;

};

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users