From: Luigi B. <bal...@ma...> - 2002-06-27 16:08:36
|
At 01:05 PM 6/27/02 +0200, Andre Louw wrote: >Disregard my previous rant. I got my facts a bit mixed up. I know the feeling. And vacations are still sooo far away... >Could you give me a bit more on how one would go about giving DiscountCurve >the ability to distinguish which to use? Sure. Modifying DiscountCurve so that it can use different interpolations in easy enough: you just have to declare it as: template <class DfInterpolation> class DiscountCurve : public DiscountStructure { ... blah blah ... // typedef Math::LogLinearInterpolation < remove this typedef!! // std::vector < Time >::const_iterator, // std::vector < double >::const_iterator > DfInterpolation; Handle < DfInterpolation > interpolation_; }; on the other hand, the instantiation would be kind of clumsy as one would be forced to write: DiscountCurve<LogLinearInterpolation < std::vector<Time>::const_iterator, std::vector<double>::const_iterator > > curve(...); Then again, we could provide a few typedefs such as: typedef DiscountCurve<LogLinearInterpolation < std::vector<Time>::const_iterator, std::vector<double>::const_iterator > > LogLinearDiscountCurve; so that the instantiation would be written as: LogLinearDiscountCurve curve(...); Also, I'm sure that there's some other syntax one could use so that one could instantiate the curve as DiscountCurve<LogLinearInterpolation> curve(...); but a) I don't remember it so I have to dig it out and b) I'm not sure that all compiler will allow it. I'll do my homework and come back. Later, Luigi |