This declares iterator
to be a variable (not a type):
typename std::vector<std::pair<T1,T2> >::iterator iterator;
Did you mean this?
typedef typename std::vector<std::pair<T1,T2> >::iterator iterator;
Further information: If you're curious about what typename
does, read up about the differences between dependent and non-dependent names. If your type is closely related to a specific container, a typedef of that container can be useful, as the STL pattern uses many nested typedefs you can easily access (V::value_type
below). This has the added advantage of requiring less change as your code evolves, e.g. using a different allocator (the second template parameter to vector), requires just one edit.
template<class T1, class T2>
struct A {
private:
// you may or may not want to expose these convenience types
typedef std::pair<T1, T2> P;
typedef std::vector<P> V;
public:
typedef typename V::value_type value_type;
typedef typename V::iterator iterator;
std::pair<iterator, bool> foo(value_type const& value_in);
};