Topic: Are template friends in *yet*?


Author: <U64533@uicvm.uic.edu>
Date: Wed, 15 Dec 1993 15:47:49 CST
Raw View
>
>In article <CHq1BL.GKs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J
>Lucas) writes:
>> Has the following (trivial) extension:
>>
>>  class C {
>>   template<class T> friend class F<T>;
>>  };
>>
>> been adopted *yet*?  It seems that too many compiler vendors
>> are strickly following the line "A template-declaration may
>> appear only as a global declaration" despite the extension
>> being amazing useful.
>>
>> I'd like a leg to stand on when I call SGI and Borland to
>> complain.
You could always do
template <class T>
class whatever
{
friend class whateverelse<T>;
...
and it's generalizations.
Otherwise you could write your own compiler.
-------------------
Thaddeus L. Olczyk






Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Wed, 8 Dec 1993 14:52:31 GMT
Raw View
 Has the following (trivial) extension:

  class C {
   template<class T> friend class F<T>;
  };

 been adopted *yet*?  It seems that too many compiler vendors
 are strickly following the line "A template-declaration may
 appear only as a global declaration" despite the extension
 being amazing useful.

 I'd like a leg to stand on when I call SGI and Borland to
 complain.
--
 - Paul J. Lucas
   AT&T Bell Laboratories
   Naperville, IL




Author: jhs@edg.com (John H. Spicer)
Date: Thu, 9 Dec 1993 14:34:21 GMT
Raw View
In article <CHq1BL.GKs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
> Has the following (trivial) extension:
>
>  class C {
>   template<class T> friend class F<T>;
>  };
>
> been adopted *yet*?  It seems that too many compiler vendors
> are strickly following the line "A template-declaration may
> appear only as a global declaration" despite the extension
> being amazing useful.
>
> I'd like a leg to stand on when I call SGI and Borland to
> complain.
>--
> - Paul J. Lucas
>   AT&T Bell Laboratories
>   Naperville, IL

There is a proposal (written by me) before the ANSI/ISO committee to
adopt such a feature.  It has been reviewed and approved by the extensions
working group.

It has not been formally approved yet, however.

I would not personally characterize this as a trivial extension.  Not
a terribly large one perhaps, but not trivial either.

John Spicer
Edison Design Group
jhs@edg.com






Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: 9 Dec 93 19:05:05 GMT
Raw View
In article <CHq1BL.GKs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
> Has the following (trivial) extension:
>
>  class C {
>   template<class T> friend class F<T>;
>  };
>
> been adopted *yet*?  It seems that too many compiler vendors
> are strickly following the line "A template-declaration may
> appear only as a global declaration" despite the extension
> being amazing useful.
>
> I'd like a leg to stand on when I call SGI and Borland to
> complain.

 Its not trivial and its not necessary. Just make
all of class C public.

 And dont complain about loss of encapsulation.
Because the above friend declaration throws out protection anyhow.

 class Thief {};
 struct F<Thief> {
  static void steal(C* c) { c->private_member ... }
 };

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
 Maxtal Pty Ltd,      CSERVE:10236.1703
        6 MacKay St ASHFIELD,     Mem: SA IT/9/22,SC22/WG21
        NSW 2131, AUSTRALIA