I would like to know if the following is allowed:
template < class C >
void function(C&);
void function() {
class {} local;
function(local);
}
thanks
I would like to know if the following is allowed:
template < class C >
void function(C&);
void function() {
class {} local;
function(local);
}
thanks
It's not allowed right now. But it's supported in C++0x. The current Standard says at
14.3.1/2
That said, if the function is also local, there's no problem
It's allowed if you use polymorphism instead of templates. Or if you don't need to extend the interface seen by
function
, simple inheritance will do.