Hi,
I've a problem getting the following code to compile (boiled down to the minimum):
Code:
#include <iostream>
class Foo {
public:
Foo() {};
template<typename T>
void print() const {
T con;
std::cout << "Foo! " << con << std::endl;
};
};
template<typename S, typename T>
class op : public std::unary_function<T*, void> {
public:
void operator()(T* t) {
t->print<S>();
};
};
int main() {
op<int, Foo> p;
p(new Foo());
}
The error g++ gives me is:
Code:
> g++ -o test test.cpp
test.cpp: In member function 'void op<S, T>::operator()(T*)':
test.cpp:18: error: expected primary-expression before '>' token
test.cpp:18: error: expected primary-expression before ')' token
g++ is version 4.1.2 20061115 on a x86_64 debian 4.0. If I change the line
to
Code:
t->Foo::print<S>();
the program compiles, but I can't use this... The problem looks like a name resolution problem. I tried to google, but haven't found anything so far. Any suggestions?
Thanks,
matze