-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use make function instead of smart pointer constructor. #162
Conversation
@@ -201,8 +201,8 @@ namespace QuantLib { | |||
|
|||
MakeCms& MakeCms::withDiscountingTermStructure( | |||
const Handle<YieldTermStructure>& discountingTermStructure) { | |||
engine_ = boost::shared_ptr<PricingEngine>(new | |||
DiscountingSwapEngine(discountingTermStructure)); | |||
engine_ = boost::static_pointer_cast<PricingEngine>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the static_pointer_cast
should not be necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As engine_ is a boost::shared_ptr<PricingEngine>
static_pointer_cast make explicit an implicit conversion with no run-time impact. I usually use the cast when I know the code must be compiled on different OS , because some compiler may complain about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, is it just to be 110% safe or did you actually see a compiler having problems with it? It would be interesting to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is to be 110% safe . I tested this on Windows VS and Centos 7 gcc 4.8.5 with no problem.
Can be removed .
No description provided.