Problem with templates used in a class member.

Ram'on Garc'ia ramon@jl1.quim.ucm.es
Fri Sep 4 14:21:00 GMT 1998


On Fri, 4 Sep 1998, Carlo Wood wrote:
> (You forgot a '&' in front of fn)
> I *think* that this is not a limitation of egcs...
> Consider:
> 
> template <class P, void (P::*member)()>
> class x { };
> 
> class user {
> public:
>         user() {}
> 	void fn() {}
> 	x<user, &user::fn> a;
> };

I am not a C++ guru; however, it is usual in both C and C++ that you can
leave out the & sign for pointers to functions.

For example, 
void fn() {}

void (*function)()  = fn;

but I agree with you, the syntax &user::fn is more precise. But that is
not the problem.

Futhermore, compilers based on the EDG frontend compile this code without
problems; for example, you can test Portland Group C++. A demostration
version for Linux and Solaris is available at ftp.pgroup.com:/x86, its
only limitation is that it lasts for 15 days. The 

I do not have a copy of the C++ standard; I can read the 1996 working
paper. Therefore, I usually relay on EDG based compilers, since this
frontend was written by members of the C++ ANSI/ISO commitee.

Ramon




More information about the Gcc mailing list