'C++ How To Make Template Accept Certain Types [duplicate]
I am making a entity component system, Where I can add a Object/Type to my entity:
template<typename ComponentType>
void addComponent(){}
But with this approach, I can make any object and send it as a parameter and I dont want that. I want only certain types to be allowed, but more specifically, I want all the objects/types that extend Component to be allowed. Note: that Component will be a base class for all other types that extend this.
Long story short how do I make this so I can only pass types to the template that are a child of this base class???
Is this possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|