This is the mail archive of the gcc-bugs@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]

Compilation error with templates


EGCS (version egcs-2.90.29 980515) fails to compile the 
following code. This code compiles correctly with the C++
compiler from Portland, so I believe that it is correct.

If this problem has been already fixed, please let me know.

EGCS gives the following errors:

kk.cc:17: incomplete type `user_cls' does not have member `get_a'
kk.cc: In method `user_cls::user_cls()':
kk.cc:16: warning: assignment to `int' from `user_cls *' lacks a cast

--------------------------------------------------------
#include <iostream>


template <class P, class Q, Q (P::*fn)() >
class property {
private:
	P *p;
public:
	property(P *pp): p(pp) {}
	operator Q() { return (p->*fn)();}
};

class user_cls {
public:
	int get_a() {return 0;}
	user_cls(): x(this) {}
	property<user_cls, int, &user_cls::get_a> x;
};


int main()
{
	user_cls pepe;
	cout << pepe.x << '\n';
}
--------------------------------------------------------------



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