I'm trying to add some typedef to my class, but the compiler reports a syntax erron on the following code:
template<class T>
class MyClass{
typedef std::vector<T> storageType; //this is fine
typedef storageType::iterator iterator; //the error is here
but the next does not work too:
typedef std::vector<T>::iterator iterator;
I was looking for the answers on many forum but i can't find a solution or workaround for this. Thank you for your help!
You are missing a typename
:
typedef typename std::vector<T>::iterator iterator;
There are a lot of similar question. E.g. take a look at the following:
std::vector<T>::iterator
is a dependent type so you need to add typename before it.
typedef typename std::vector<T>::iterator iterator;
^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With