|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
c++.beta - friend of a class template
template<class T>
struct A;
template<class T>
void f();
template<class T>
struct A
{
friend void f<T>();
// Error: 'f' is not a class template
};
int main()
{
A<int> a;
return 0;
}
See 14.5.3 Friends [temp.friend], paragraph 1.
Extracted from Boost's format library.
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Jun 27 2003
and a similar one with an operator:
template<class T>
struct A;
template<class T> void f(const A<T> &a, int i)
{
if (a.i == i);
}
template<class T> void operator << (const A<T> &a, int i)
{
if (a.i == i);
}
template<class T>
struct A
{
friend void f<T>(const A<T> &, int i);
// Error: 'f' is not a class template
friend void operator << <T>(const A<T> &, int i);
// Error: only classes and functions can be friends
private:
int i;
};
int main()
{
A<char> a;
f(a, 0);
a << 0;
return 0;
}
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
Aug 22 2003
|