This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problem with templates used in a class member.


| 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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]