0

I'm trying to scope to the generic type of a template, like this:

template<typename T> void doSomething(T::SomeScopedType t) {...}

However, this leads to the compiler errors: variable or field ‘doSomething’ declared void expected ‘)’ before ‘t'

Is it possible to scope a generic type?

Lenny
  • 388
  • 3
  • 15
  • Use the `typename` keyword to instruct the compiler that `T::SomeScopedType` names a type, e.g. `... doSomething(typename T::SomeScopedType t) ...`. A call to `doSomething` will likely need to be explicitly instantiated (e.g. `doSomething(...);` (T = SomeType). – Peter Huene Aug 22 '17 at 23:50
  • 1
    Thanks! I wasn't aware an answer had already existed – Lenny Aug 23 '17 at 00:40

0 Answers0