Possible duplicate:
How to use local classes with templates?
g ++ 4.4 refuses to compile a call to a template function, taking a local-local class as a template parameter. For instance:
template <typename C>
int f(const C& c) {
return c.g();
}
struct C1 {
int g() const { return 42; }
};
int h1() {
return f(C1());
}
int h2() {
struct C2 {
int g() const { return 42; }
};
return f(C2());
}
int h3() {
struct C3 {
int g() const { return 42; }
};
return f<C3>(C3());
}
What gives? How to do it? (In the real program from which it is truncated, “h” is a member function, and “C” must be a nested class, so that it is implicitly a friend of the class of which “h” is a member.)
source
share