In C++03 you are not allowed to declare friendship to an argument of the template.
§7.1.5.3/2
[...] If the identifier resolves to a typedef- name or a template type-parameter, the elaborated-type-specifier is ill-formed. [Note: this implies that, within a class template with a template type-parameter T, the declaration
friend class T;
is ill-formed. ]
In C++11 there has been some changes to this respect, but it is a bit weird. friend class T;
is still illformed, but friend T
is allowed. A quote can be found in the same paragraph:
§7.1.5.3/2
[...] [ Note: This implies that, within a class template with a template type-parameter T, the declaration
friend class T;
is ill-formed. However, the similar declaration friend T; is allowed (11.3). — end note ]
Notes are not normative, but they indicate the intent of the norms around it. I have not been able to find the specific sentence that makes the note correct, but I assume that at least the intention is that this should be allowed.