I have a function template that looks like this:
template <typename T>
std::shared_ptr<T> GetComponent()
{
for (auto const& c : Components)
{
if (std::dynamic_pointer_cast<T>(c))
{
return std::dynamic_pointer_cast<T>(c);
}
}
return nullptr;
}
And I'm trying to call it from another function template:
std::shared_ptr<GameObject> Object;
template <typename T>
std::shared_ptr<T> GetComponent()
{
return Object->GetComponent<T>();
}
But I get
syntax error: unexpected token ')', expected 'expression'