-1

I have the following template class.

template <typename _Type, typename _Comparator = equal_to<_Type> >
class CSearch
{
...
};

It should store STL stuffs like list, set or string. I store all elements (for example strings) in private class member:

map<int,_Type> seqs;

Now I want to use iterator, but there is a problem with <_Type>::const_iterator.

template <typename _Type, typename _Comparator>
void CSearch<_Type,_Comparator>::Foo1(int id, const _Type & needle)
{
seqs.insert(make_pair(id,needle));

for(_Type::const_iterator it=seqs[0].begin();it!=seqs[0].end();it++)
cout<<*it<<" ";

cout<<endl;
}

or analogically

 for(map<int,_Type>::const_iterator it=seqs.begin();it!=seqs.end();it++)
 cout<<*it<<" ";
user1890078
  • 207
  • 1
  • 2
  • 7

1 Answers1

1

<_Type>::const_iterator is a dependent type.

Refer to it as typename <_Type>::const_iterator instead.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055