Assuming these classes are all polymorphic/dynamic (which they need to be to use typeid like this), you can just use dynamic_cast instead:

~~~
template <typename T> T* GetComponent() {
    for (Component* c : _components) {
        if (T *tc = dynamic_cast<T *>(c)) return tc;
    }
    return nullptr;
}
~~~