Reputation: 910
I have a class that looks like this:
template<typename T>
class MyContainer
{
public:
struct Handle
{
public:
T* Resolve();
};
private:
vector<Handle> mHandles;
};
It seems like they won't compile the iterator for the handles when I am using:
vector<Handle>::iterator iter = mHandles.begin();
If I change it to auto it works:
auto& iter = mHandles.begin();
Am not suppose to use the type explicitly?
Upvotes: 1
Views: 78
Reputation: 6016
vector<Handle>::iterator
is a dependent name, hence you must include a typename
before it, when you use it inside a template function/class
Simply change
vector<Handle>::iterator iter = mHandles.begin();
to
typename vector<Handle>::iterator iter = mHandles.begin();
will work.
Upvotes: 5