[Ipopt] Assign SmartPointer of child class to SmartPointer of base class

Uwe Nowak uwe.nowak at itwm.fraunhofer.de
Tue Feb 1 11:46:54 EST 2011


Hello!

I have a class MyNLP that derives from Ipopt::TNLP.
Now I have a smart pointer Ipopt::SmartPtr<MyNLP> to this instance. 
However I have to pass a Ipopt::SmartPtr<Ipopt::TNLP> to the 
Application->OptimizeTNLP-Method.

Unfortunately the Smart Pointer is not automatically converted (as I was 
used from the boost shared_ptr).

I know, that I can create a Ipopt::SmartPtr<Ipopt::TNLP> holding a 
reference to my MyNLP. But then I have to do a dynamic cast all the time 
when I want to access MyNLP-Methods not in TNLP.

So what is the best way to have a reference to MyNLP and pass this in TNLP?

Thank You,
Uwe



More information about the Ipopt mailing list