Possible Duplicate:
Template Constraints C++
I am wondering if I can check to see if type T inherits a certain class in my generic/templated methods. I can do this easily in C# using 'where'. For example, in my game engine, I have this concept of a generic manager that is an XNA component. It has a list of drawable objects (Could be entities, particles, etc). So my class definition is like this:
public class LayerableDrawableGenericManager<T> : Microsoft.Xna.Framework.DrawableGameComponent where T : Drawable
So we can only have a generic manager of an object that can be drawn (an object that inherits drawable). We need to be sure of this because in my generic manager, I am calling Draw()
on all those T type objects. Without ensuring that the T type object will inherit the Drawable class (which contains the Draw()
method), I wouldn't be able to draw my objects.
anyway, Was wondering how this is done in C++. I've googled around for things like "Where C++" and "Where keyword C++" and all my results are things like "where can i learn C++"..