This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with templates used in a class member.
- To: "Ram'on Garc'ia" <ramon at jl1 dot quim dot ucm dot es>
- Subject: Re: Problem with templates used in a class member.
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 10 Sep 1998 11:08:40 z
- Cc: egcs at cygnus dot com
- References: <Pine.LNX.3.96.980909163527.16552A-100000@jl1.quim.ucm.es>
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