Possible Duplicate:
c++ template typename iterator
Consider such code:
#include <map>
#include <boost/shared_ptr.hpp>
template <typename T>
class Test
{
typedef std::map< int, boost::shared_ptr<T> > TMap;
TMap myMap;
void test()
{
TMap::const_iterator iter = myMap.begin(); // line 12
}
};
After normal compilation with g++ main.cpp
following lines are returned:
main.cpp: In member function ‘void Test<T>::test()’:
main.cpp:12: error: expected ‘;’ before ‘iter’
If I change std::map< int, boost::shared_ptr<T> >
to std::map< int, int >
, then it compiles.
It seems that there is a problem with template object boost::shared_ptr<T>
passed as a parameter to another template object.
- Why?
- How to fix this?