Login  Register

Re: quantlib Handle compile error

Posted by simoncourtenage on May 24, 2010; 6:38am
URL: http://quantlib.414.s1.nabble.com/quantlib-Handle-compile-error-tp7722p7737.html

The problem is the temporary.  C++ doesn't allow binding a temporary to a non-const reference.

Simon Courtenage

On Mon, May 24, 2010 at 6:35 AM, P Nelnik <[hidden email]> wrote:
Happy Monday all,

When trying to use the quantlib Handle<.>, I got a compiler error:

>c:\work\quantlib\quantlib-1.0.1\ql\handle.hpp(143) : error C2664: 'QuantLib::Observer::unregisterWith' : cannot convert parameter 1 from 'boost::shared_ptr<T>' to 'const boost::shared_ptr<T> &'

Though I haven't changed anything in handle.hpp.
Here's the code that generates the error:

class Foo
{
public:
    Integer i;
    Foo() { i = 0; }
};

int main()
{
        Handle<Foo> c ( boost::shared_ptr<Foo>(new Foo()));
        return 0;
}


Any ideas what's the cause or solution?

Thanks
Philip

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


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




--
------------------------------------------------------------------------
Simon Courtenage                     | simoncourtenage.wordpress.com
Twitter: simoncourtenage         | Skype: simon99ctg
Facebook: Simon Courtenage   | IM: [hidden email]  

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


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