help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can specializations of a template class be mutual friends ?


From: Ulf Rehmann
Subject: Re: How can specializations of a template class be mutual friends ?
Date: Sat, 10 Mar 2001 00:09:32 +0100

Similar result. This is the answer of g++:

ttt.cc:10: class `complex<Scalar>' is implicitly friends with itself
ttt.cc: In method `complex<double>::complex<float>(const complex<float> &)':
ttt.cc:14:   instantiated from here
ttt.cc:3: `float complex<float>::re' is private
ttt.cc:7: within this context
ttt.cc:3: `float complex<float>::im' is private
ttt.cc:7: within this context


The proposed standard seems to admit friend declarations like
this. This is an excerpt from the proposed standard:

14.5.3  Friends                                          [temp.friend]

1 A friend function of a class template can be a function template or an
  ordinary (non-template) function.  [Example:
          template<class T> class task {
              // ...
              friend void next_time();
              friend task<T>* preempt(task<T>*);
              friend task* prmt(task*);           // task is task<T>
              friend class task<int>;
              // ...
          };
  Here,  next_time()  and  task<int> become friends of all task classes,
  and each task has appropriately typed functions preempt()  and  prmt()
  as  friends.  


So may be g++ does not conform with the standard.

Thanks for your help!

Best regards,
Ulf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]