How can I specialize a class template so that the template parameters can be of type : a pointer to a particular class or a pointer to the derived class of that particular type? Is it possible to do it without using Boost?
Possible Duplicate of: C++ templates that accept only certain types
I just wanted to know whether the answer is same even if I am using a pointer to the instances .
You could specialize your class for pointers and then use
std::is_base_ofwith astatic_assert:See it in action. Both
std::is_base_ofandstatic_assertare C++11 features so no Boost is required.If for some reason you don’t like
static_assert, you could do it theenable_ifway: