member-template bug in egcs

Michael A. Benzinger mbenz@sabre.com
Mon Nov 24 04:59:00 GMT 1997


At 02:18 AM 11/21/97 -0200, Alexandre Oliva wrote:
>Michael A Benzinger writes:
>
>> In other words, you can construct a complex<T1> from a complex<T2> if and
>> only if you can initialize a T1 by a T2.  That seems reasonable."
>
>It really does, but, unless I've missed some important part of the
>standard, a specialization of a template class does not implicitly
>gain priviledged access to another specialization of the same template
>class.
>
"A class or a class template can have members that are themselves templates.
For example:

  template<class Scalar> class complex {
       Scalar re, im;
  public:
       template <class T>
            complex(const complex<T>& c) : re(c.re), im(c.im) { }
       // ...
};

What Klaus is trying to do here is create a "template member FUNCTION".
This is not a definition of a new template CLASS.  A template member
function DOES have access to the private members of a template class.

You can also consult Scott Meyers' "Effective C++, Second Edition"
for more information on this.

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