Topic: Do templates and friends mix ?
Author: "Timo Geusch" <106167.1541@compuserve.com>
Date: 1996/10/05 Raw View
{ I set followups to comp.std.c++. -vdv }
Hello everyone,
I ran into an interesting problem today. According to my copy of the C++
draft standard, the following code should be legal (see section 14.12.2):
template<class Type, long lKeyType> class Lock;
////////////////////////////////////////////////////////////////////////////
///
// --- Class Key --- //
////////////////////////////////////////////////////////////////////////////
///
class Key //
{
public:
Key ();
Key (const Key&);
protected:
private:
template<class Type, long lKeyType> friend class Lock;
};
However, MS Visual C++ 4.2 will abort compilation in the line defining the
"friend", stating that 'template' was an unexpected token. IMHO, this
should be legal code. Can anyone comment on this ? Is it a compiler
bug/problem or did I just get something wrong ?
Thanks,
Timo
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]