Cpp template constraint

template <typename T>
T* GetComponent()
{
static_assert(std::is_base_of<Component, T>::value, "The function call GetComponent<T>() requires T to inherit from Component!");

return (T*)components.at(0);
}

 

Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*