I have a template class which contains a vector of pointers of a type given as a template parameter. I want to be able to use range-based iteration to iterate over a limited portion of the vector. My class contains the following functions:
template< typename ObjectType >
class ObjectList
{
...
public:
//! Begin iteration over a list of objects
std::vector<ObjectType*>::iterator begin();
//! Iterator to one past the end of the list of objects
std::vector<ObjectType*>::iterator end();
private:
std::vector<ObjectType*> object_ptrs;
};
This fails to compile with the description Error C2061 syntax error: identifier 'iterator'
. I can't think of any reason why std::vector<ObjectType>::iterator
should ever not be found, unless ObjectType
itself cannot be found, but the rest of the class instantiates successfully if I remove the lines which reference iterator
.
Anyone have an idea what is going on? I'm sure it's possible I'm missing something obvious. Thanks in advance!