problem with templates and iterators
Ryan Boder
icanoop@bitwiser.org
Wed Dec 15 18:07:00 GMT 2004
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
More information about the Gcc
mailing list