Re: May a template argument be a friends of the template class?
From: Malte Starostik (malte_at_starostik.de)
Date: 03/29/05
- Next message: Mark A. Gibbs: "Is wchar_t guaranteed to be larger than char?"
- Previous message: Victor Bazarov: "Re: May a template argument be a friends of the template class?"
- In reply to: Victor Bazarov: "Re: May a template argument be a friends of the template class?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 04:28:23 +0200
Victor Bazarov schrieb:
> I don't know about g++ 3.4.2 but Comeau C++ (online trial) refuses to
> compile
>
> template<class T> class A {
> friend class T;
> int a;
> };
>
> explaining that 'T' "may not be used in an elaborate type specifier",
> although I can't find anything against it in the Standard. [Aside:
> it would really be nice if compilers in the cases where they give
> diagnostic messages re ill-formed code, supplied at least the clause
> of the Standard related to the issue, better if it were the paragraph]
Full Ack.
> It would be nice if somebody more versed in the Standard explained...
11.4 Friends, paragraph 2 requires an elaborated-type-specifier for a
friend declaration of a class.
7.1.5.3 Elaborated type specifiers, paragraph 2 explicitly refers to it:
[...] 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]
Not that I have any idea about the rationale for this...
Cheers,
Malte
- Next message: Mark A. Gibbs: "Is wchar_t guaranteed to be larger than char?"
- Previous message: Victor Bazarov: "Re: May a template argument be a friends of the template class?"
- In reply to: Victor Bazarov: "Re: May a template argument be a friends of the template class?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|