P
Pete C.
I'm trying to make a templated function a friend like this:
class cls
{
...
friend cls func<> (const cls& a, const cls& b);
};
template< template<class> class Op>
cls func (const cls& a, const cls& b)
{
...
}
That seems to be what TC++PL SE shows in C.13.2, but the compiler seems to
be interpreting it as a data declaration:
error C2143: syntax error : missing ';' before '<'
error C2460: 'func' : uses 'cls', which is being defined: see declaration of
'cls'
error C2433: 'func' : 'friend' not permitted on data declarations
error C2238: unexpected token(s) preceding ';'
The compiler docs on those diagnostics don't seem to have anything to do
with friend.
What am I doing wrong?
Thanks!
- Pete
class cls
{
...
friend cls func<> (const cls& a, const cls& b);
};
template< template<class> class Op>
cls func (const cls& a, const cls& b)
{
...
}
That seems to be what TC++PL SE shows in C.13.2, but the compiler seems to
be interpreting it as a data declaration:
error C2143: syntax error : missing ';' before '<'
error C2460: 'func' : uses 'cls', which is being defined: see declaration of
'cls'
error C2433: 'func' : 'friend' not permitted on data declarations
error C2238: unexpected token(s) preceding ';'
The compiler docs on those diagnostics don't seem to have anything to do
with friend.
What am I doing wrong?
Thanks!
- Pete