member-template bug in egcs
Michael A. Benzinger
mbenz@sabre.com
Wed Nov 19 08:56:00 GMT 1997
Klaus-Georg,
The code is correct. Member templates are valid according to
Bjarne Stroustrup's "The C++ Programming Language". The compilers,
including Microsoft's Visual C++ 5.0, are still to catch up on this.
Using this compiler, I get the same error as you. I would suspect
that this is either a bug in egcs or this functionality has not yet
been implemented.
Mike Benzinger
At 03:06 PM 11/19/97 +0100, Klaus-Georg Adams wrote:
>
>I believe the following program should compile:
>
>template <class T> class t {
>public:
> template <class T2> void access( const t<T2>& x ) { data = x.data; }
>private:
> int data;
>};
>
>int main()
>{
> t<int> one;
> t<long> two;
> one.access( two );
> return 0;
>}
>
>egcs (971105 and 971114) complains:
>
>/egcs/egcs/bin/g++ -o tt tt.C
>tt.C: In method `void t<int>::access(const class t<long int> &)':
>tt.C:3: member `data' is a private member of class `t<long int>'
>
>Should I be wrong and egcs right, what would be the appropriate friend
>declaration to poke this through egcs?
>
>-- kga
>-------------------------------------------------------------------------
>Klaus-Georg Adams Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
>Institut f. Anorg. Chemie II Tel: 0721 608 3485
>Uni Karlsruhe
>-------------------------------------------------------------------------
>
>
-------------------------------------------------------------
Michael A. Benzinger
Principal
SABRE Technology Solutions Phone: +1 817-264-6820
1 E. Kirkwood Blvd. Fax: +1 817-264-3504
Southlake, TX 76092 e-mail: mbenz@sabre.com
U.S.A. bzinger@iName.com
More information about the Gcc-bugs
mailing list