In a derived class template (which is most likely what you mean) you can do
using Component = typename System<T>::Component;
where T is some suitable type in the derived class.
Turning to the template, you can do this:
template< class U > using Component = typename System<T>::template Component<U>;
as noted by dyp in the comment.
Details depend on the context, here is a specific example for your code given in the message edition:
class ET { public: template< class Type > struct Component {}; }; template<class EntityManager> class System { public: virtual void Update(EntityManager& entity_manager, double dt) = 0; protected: template<typename T> using Component = typename EntityManager::template Component<T>; }; template< class EntityManager > class MovementSystem : public System<EntityManager> { public: #ifndef DONTFIXIT template< class T > using Component = typename EntityManager::template Component< T >; #endif virtual void Update(EntityManager& entity_manager, double dt) { Component<int> position_component; // I'd like to use Component<T> here. } }; auto main() -> int { MovementSystem< ET > ms; }
There is no easy way to do this, sorry.
This is, of course, an area where the main language can support the programmer much better, avoiding repeating the name over and over.
The rationale for the language is that some System specializations may not necessarily determine the type of Component or available.
With using you enable the compiler to diagnose the absence of this type in front.
Cheers and hth. - alf
source share