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]

Re: Yet another template bug in gcc-2.95.1


On Aug 29, 1999, "Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de> wrote:

>> The main problem is that the member function operators interact with the
>> friend operators although they take different arguments.

> Thanks for your bug report. I'm not too sure whether the bug is in
> your code or in g++. What exactly is the friend declaration supposed
> to declare as a friend?

I read the code as declaring a particular specialization of the
template function as a friend.

> And where in the standard is that supposed to be supported?

[temp.friend]/1:

template<class T> task<T>* preempt(task<T>*);
template<class T> class task {
[snip]
          friend task<T>* preempt<T>(task<T>*);

[temp.arg.explicit]/2:
[...]
  Trailing template arguments that can be deduced (_temp.deduct_) may be
  omitted  from  the list of explicit template-arguments.

> Anyway, a work-around is to write

>   template <class T> friend
>   ptrdiff_t operator- (const _r__It <T>& x, const _r__It <T>& y);

Yup, but, as you probably already know, this is much more permissive,
since it grants privileged access to *all* specializations of the
template function.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


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