http://quantlib.414.s1.nabble.com/allocating-an-object-of-abstract-class-type-error-tp17968p17972.html
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.
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
------------------------------------------------------------------------------
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