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: ramon at jl1 dot quim dot ucm dot es (Ram'on Garc'ia)
- Subject: Re: Problem with templates used in a class member.
- From: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Date: Fri, 4 Sep 1998 03:54:12 +0200 (CEST)
- Cc: egcs at cygnus dot com (egcs at cygnus dot com)
| template <class P, void (P::*member)()>
| class x { };
|
| class user {
| public:
| user() {}
| void fn() {}
| x<user, fn> a;
| };
(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;
};
Which gives the error:
foo.cc:8: incomplete type `user' does not have member `fn'
Its a fact that `user' is incomplete at that point.
You can do:
class user {
public:
user() {}
void fn() {}
};
class user_derived : public user {
public:
x<user, &user::fn> a;
};
which compiles fine.
--
Carlo Wood <carlo@runaway.xs4all.nl>