Re: reference of boost::shared_ptr instead of Handle

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/reference-of-boost-shared-ptr-instead-of-Handle-tp7623p7624.html

On Thu, 2009-08-27 at 17:14 +1000, Yan Kuang wrote:
> First of all, I found some classes of Quantlib have no default
> constructor. This mean users have to create object on the heap.

How are the two things related? You can create objects on the stack just
the same. You'll just have to pass arguments to the constructor instead
of just declaring the object.

> Is this intentional, as I tentatively want to add default constructor
> for the class I am using.

If there's no default constructor, it probably makes no sense to have
one. The default-constructed object wouldn't have enough information to
work anyway.


> Anyway in the case of no default constructor, we use
> boost::shared_ptr. I read appendixA.pdf of Quantlib doc: Handle is
> designed
> to replace pointer to pointer. But I think passing reference of
> boost::shared_ptr in a function call will have same effect. I could be
> wrong,
> any comments?

I'm not sure I understand. If the function takes a Handle, you'll have
to use one since there's no automatic conversion from boost::shared_ptr.
Or do you want to write the function instead?

Luigi


--

If you can't convince them, confuse them.
-- Harry S. Truman



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users