I have a template class compiling fine in VC6. But it is not compiling in VC9. For that I have added "typename" keyword in front of one type. After this it is compiling in vc9 but not in VC6. How do I make it compiling with both the compilers.
#include <map>
#include <vector>
template <class T1, class T2>
class A
{
public:
std::pair<typename std::vector<std::pair<T1,T2> >::iterator, bool > insert(const std::pair<T1 ,T2> &value_in);
};
template <class T1, class T2>
std::pair< std::vector<std::pair<T1,T2> >::iterator, bool> A<T1,T2>::insert(const std::pair<T1 ,T2>& value_in)
{
std::pair< std::vector<std::pair<T1,T2> >::iterator, bool> b;
return b;
}
void main()
{
A<int, int> a;
a.insert(std::pair<int, int>(0, 0));
}
Above code compiles in VC6. But not in VC9. Following code works in VC9, not in VC6.
#include <map>
#include <vector>
template <class T1, class T2>
class A
{
public:
std::pair<typename std::vector<std::pair<T1,T2> >::iterator, bool > insert(const std::pair<T1 ,T2> &value_in);
};
template <class T1, class T2>
std::pair<typename std::vector<std::pair<T1,T2> >::iterator, bool> A<T1,T2>::insert(const std::pair<T1 ,T2>& value_in)
{
std::pair< std::vector<std::pair<T1,T2> >::iterator, bool> b;
return b;
}
void main()
{
A<int, int> a;
a.insert(std::pair<int, int>(0, 0));
}