auto_ptr inside map

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <map>
#include <memory>
#include <string>
using namespace std;

template <typename T>
void fns(void)
{
        typedef auto_ptr<T> Tptr;
        map<string,Tptr>::iterator it;
}

int main ()
{
  return 0;
}




I know auto_ptr should not be used in stl container,but why is this code giving error

1
2
del.C: In function `void fns()':
del.C:10: error: expected `;' before "it"



As iterator is a typename the compiler needs a hint:
 
typename map<string, Tptr>::iterator it;
Topic archived. No new replies allowed.