Re: Question about elaborate CRTP - is the friend declaration ill-formed?
Mikhail Parakhin ha scritto:
The fact that we have template template parameters is irrelevant, even
with non-template template parameters it would be ok.
I don't quite understand what you mean. My understanding is that template
template parameter is the gist here. If it wasn't template template
parameter, it would be something like
template <class P_Policy>
class T_MyClass
{
friend class P_Policy; // Illegal - resolves to "template
type-parameter"!
};
Oh, now I understand your point. That's illegal, but not because
"P_Policy" is a *type* parameter, but simply because it is the name of a
parameter *used alone*. But if the parameter is used as part of a
template-id, then it's legal:
template <template<class >class P_Policy>
class T_MyClass
{
friend class P_Policy<T_MyClass<P_Policy> >; // legal!
};
template <class P_Policy>
class T_MyClass
{
friend class AnyTemplate<P_Policy>; // legal!
};
They're both legal because "P_Policy<T_MyClass<P_Policy> >" and
"AnyTemplate<P_Policy>" are template-ids.
Ganesh
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]