Problem with templates used in a class member.

Alexandre Oliva oliva@dcc.unicamp.br
Thu Sep 10 17:58:00 GMT 1998


Ram'on Garc'ia <ramon@jl1.quim.ucm.es> writes:

> template <class P, void (P::*member)()> class x { };
> class user { public: user() {} void fn() {} x<user, &user::fn> a; };

> is legal in C+ and is not supported by EGCS.

> I have read the source code of the C++ frontend of EGCS. I found the
> problem, but I think that is very difficult to solve.

The correct approach to fix this problem is to allow the address of a
member to be taken even if the class is not yet fully defined (but it
must not be just a forward-declared class or template specialization).
The test of whether the class type is completely defined should not be
performed in this case.  Unfortunately, I don't have the faintest idea
of how to map these ideas onto the existing code.

> An approach could be to delay the instatation of the template until
> the declaration of the class is complete, probably placing some
> hooks in the class node.

I believe this might introduce some problems related with point of
instantiation of templates.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc mailing list