http://quantlib.414.s1.nabble.com/allocating-an-object-of-abstract-class-type-error-tp17968p17979.html
For example what about TermStructure, it is abstract, but no template class.
> Hi Peter
>
> I haven't started template classes yet, below are abstract classes I found
>
> Commodity
>
> CmsSpreadCouponPricer
>
> EquityFXVolSurface
>
> InterestRateVolSurface
>
> MarketModelComposite
>
> MultiProductMultiStep
>
> MultiProductOneStep
>
> Option
>
> DefaultDensityStructure
>
> SurvivalProbabilityStructure
>
> SwaptionVolatilityCube
>
> SwaptionVolatilityDiscrete
>
>
> Regards
> Jerry
>
> On Thu, Jan 19, 2017 at 8:19 PM, Peter Caspers <
[hidden email]>
> wrote:
>>
>> Hi Jerry,
>>
>> just out of interest, can you post some statistics on that here?
>>
>> Kind Regards
>> Peter
>>
>> On 19 Jan 2017, at 03:52, Jerry Jin <
[hidden email]> wrote:
>>
>> Hi Yannis
>>
>> Thank you, for now I'm using compiler to tell me which class is abstract,
>> it's not too many
>>
>> Regards
>> Jerry
>>
>> On Wed, Jan 18, 2017 at 2:07 AM, Yannis <
[hidden email]> wrote:
>>>
>>> It is definitely possible using C++ metaprogramming.
>>> One strategy could be to process all classes T regardless of whether each
>>> particular class T is abstract or not.
>>> Then rather than calling new T(arg), where arg is some argument, you
>>> should call New<T>::Res::f(arg)
>>> Above New<T> is a template class that you must define in such a way that
>>> it contains a typedef called Res, which in turn is designed to equal one of
>>> the following two classes: NewDoNothing or NewDoSomething<T>.
>>> The first class NewDoNothing must contain a static method f that does
>>> nothing.
>>> The second class NewDoSomething<T>, which is a template, must contain a
>>> static method also called f that returns new T(arg).
>>> The idea is that New<T>::Res intelligently switches between NewDoNothing
>>> and NewDoSomething<T> based upon whether T is abstract or not.
>>> This intelligent switch can be easily implemented for a generic argument
>>> arg, as long as it is a single argument.
>>> I suppose this method can be generalized for any number of arguments,
>>> including the case of no arguments at all.
>>> Let me know if this is an approach you would like to follow and I could
>>> send you some code that I have that implements this switch.
>>>
>>> Regards,
>>>
>>> Ioannis
>>>
>>>
>>> Luigi Ballabio <
[hidden email]> schrieb am 14:07 Donnerstag,
>>> 12.Januar 2017:
>>>
>>>
>>> No, I don't think there is.
>>>
>>>
>>> On Thu, Jan 12, 2017 at 2:02 PM Jerry Jin <
[hidden email]>
>>> wrote:
>>>
>>> Hi Luigi
>>>
>>> Thanks, is there any tool or document to identify which class is abstract
>>> that I can use new to allocate memory?
>>>
>>> I'm working a wrapper program, which iterate all classes, hence it would
>>> be great to know which classes I can't do 'new' before compiling
>>>
>>> Regards
>>> Jerry
>>>
>>> On Thu, Jan 12, 2017 at 7:33 PM, Luigi Ballabio
>>> <
[hidden email]> wrote:
>>>
>>> A class is abstract when it (or one of its base classes) declares a pure
>>> virtual method and doesn't define it.
>>> In your case: CmsSpreadCouponPricer inherits from
>>> FloatingRateCouponPricer, which declares a bunch of virtual methods:
>>>
>>> virtual Real swapletPrice() const = 0;
>>> virtual Rate swapletRate() const = 0;
>>> virtual Real capletPrice(Rate effectiveCap) const = 0;
>>> virtual Rate capletRate(Rate effectiveCap) const = 0;
>>> virtual Real floorletPrice(Rate effectiveFloor) const = 0;
>>> virtual Rate floorletRate(Rate effectiveFloor) const = 0;
>>> virtual void initialize(const FloatingRateCoupon& coupon) = 0;
>>>
>>> so FloatingRateCouponPricer is abstract. CmsSpreadCouponPricer doesn't
>>> define them, so it's also abstract. LognormalCmsSpreadPricer inherits from
>>> CmsSpreadCouponPricer and defines them (that is, gives them actual bodies)
>>> so it's a concrete class and can be instantiated.
>>> For more details, you can probably check any C++ book.
>>>
>>> Cheers,
>>> Luigi
>>>
>>>
>>> On Thu, Jan 12, 2017 at 4:52 AM Jerry Jin <
[hidden email]>
>>> wrote:
>>>
>>> Hello, QuantLib community
>>>
>>> I'm getting error 'allocating an object of abstract class type error'
>>> sometimes while working with some classes
>>>
>>> For example:
>>>
>>> return new CmsSpreadCouponPricer(correlation);
>>>
>>> How do I know which class is abstract and can't allocate memory?
>>>
>>> Thanks!
>>>
>>> Regards
>>> Jerry
>>>
>>> ------------------------------------------------------------------------------
>>> Developer Access Program for Intel Xeon Phi Processors
>>> Access to Intel Xeon Phi processor-based developer platforms.
>>> With one year of Intel Parallel Studio XE.
>>> Training and support from Colfax.
>>> Order your platform today.
>>>
http://sdm.link/xeonphi_______________________________________________>>> QuantLib-users mailing list
>>>
[hidden email]
>>>
https://lists.sourceforge.net/lists/listinfo/quantlib-users>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Developer Access Program for Intel Xeon Phi Processors
>>> Access to Intel Xeon Phi processor-based developer platforms.
>>> With one year of Intel Parallel Studio XE.
>>> Training and support from Colfax.
>>> Order your platform today.
http://sdm.link/xeonphi>>>
>>> _______________________________________________
>>> QuantLib-users mailing list
>>>
[hidden email]
>>>
https://lists.sourceforge.net/lists/listinfo/quantlib-users>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org!
>>
http://sdm.link/slashdot_______________________________________________>> QuantLib-users mailing list
>>
[hidden email]
>>
https://lists.sourceforge.net/lists/listinfo/quantlib-users>>
>>
>