can't take address of static template member funcion?

Corey Kosak kosak@cs.cmu.edu
Sun May 24 15:20:00 GMT 1998


> > >   void (*fp)()=&cow().template func<int>; // error
> [...]
> > void (*fp)() = &cow::template func<int>;
> > 
> 
> I think both notations are valid. The first one creates a temporary
> cow, and accesses its (static) (template) member function.

No.  A temporary is not created [and g++ correctly does not create one]:


r.9.4, Stroustrup, 2nd ed.  A static member mem of class cl can be
referred to as cl::mem (sec r.5.1), that is, independently of any
object.  In can also be referred to using the . and -> member access
operators (sec 4.5.2.4).  When a static member is accessed through a
member access operator, the expression on the left side of the . or ->
is not evaluated.



More information about the Gcc-bugs mailing list