public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Compilation error with templates
@ 1998-08-19 14:51 Ram'on Garc'ia
0 siblings, 0 replies; only message in thread
From: Ram'on Garc'ia @ 1998-08-19 14:51 UTC (permalink / raw)
To: egcs-bugs
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';
}
--------------------------------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-08-19 14:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-19 14:51 Compilation error with templates Ram'on Garc'ia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).