This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
problem with templates and iterators
- From: Ryan Boder <icanoop at bitwiser dot org>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 15 Dec 2004 13:07:02 -0500
- Subject: problem with templates and iterators
I'm having trouble compiling the following code.
--------------------
#include <string>
#include <map>
#include <utility>
using namespace std;
template <class T>
class Bob {
public:
Bob() {}
void xxx(int x);
};
template <class T>
void Bob<T>::xxx(int x) {
pair<multimap<string, Bob<T>*>::iterator, int> p;
//pair<multimap<string, Bob<T>*>, int> p;
//pair<multimap<string, Bob<int>*>::iterator, int> p;
}
int main() {
return 0;
}
------------------------
The code in Bob::xxx gives a compile error but the 2 commented lines beside
it compile with no problem. Any idea why? Am I doing something wrong here?
I'm using the g++ 3.4.2 that comes with fedora core 3.
The error message is
bob.cpp: In member function `void Bob<T>::xxx(int)':
bob.cpp:19: error: type/value mismatch at argument 1 in template parameter
list for `template<class _T1, class _T2> struct std::pair'
bob.cpp:19: error: expected a type, got `
std::multimap<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >,Bob<T>*,std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
>,std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, Bob<T>*> > >::iterator'
bob.cpp:19: error: invalid type in declaration before ';' token
--
Ryan Boder
http://bitwiser.org/icanoop