Hello,
template arguments have to be specified at compile time, so I'm
afraid there's no way except a big
if (traits == "Discount" && interpolation == "Linear")
return make_shared<PiecewiseYieldCurve<Discount,Linear> >(...);
else if (traits == "Discount" && interpolation == "LogLinear")
return make_shared<PiecewiseYieldCurve<Discount,LogLinear> >(...);
To minimize inconvenience, I'd put the above inside a function so that
I'd only write it once. Then in client code I'd just write
shared_ptr<YieldTermStructure> curve = make_piecewise(traits,
interpolation, helpers, ...);
LuigiOn Wed, Jan 29, 2014 at 2:49 PM, jlee <[hidden email]> wrote:> [hidden email]> Sent from the quantlib-dev mailing list archive at Nabble.com.
> Hi all,
> Pretty new to QuantLib and have been playing with the Example sources. I
> have a question regarding the PiecewiseYieldCurve object. If I want to make
> the first two parameters (traitid and interpolatorid) an input variable how
> can I do this? Specifically, I'm looking at the swapvaluation.cpp example
> where it is using "Discount" and "LogLinear". I want to make it a user input
> so the interpolation method can be changed. Sorry it's probably more of a
> C++ question as I'm a bit weak on templates.
>
> Thank you,
> Jon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/PiecewiseYieldCurve-question-tp14918.html
>
> ------------------------------------------------------------------------------
> WatchGuard Dimension instantly turns raw network data into actionable
> security intelligence. It gives you real-time visual feedback on key
> security issues and trends. Skip the complicated setup - simply import
> a virtual appliance and go from zero to informed in seconds.
> http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-dev mailing list
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev------------------------------------------------------------------------------[hidden email]
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
If you reply to this email, your message will be added to the discussion below:http://quantlib.10058.n7.nabble.com/PiecewiseYieldCurve-question-tp14918p14919.html
Free forum by Nabble | Disable Popup Ads | Edit this page |