Title
Friend template template parameters
Status
nad
Section
11.8.4 [class.friend]
Submitter
James Widman

Created on 2006-06-15.00:00:00 last changed 197 months ago

Messages

Date: 2008-09-15.00:00:00

Rationale (September, 2008):

The proposed extension is not needed. The template case can be handled simply by providing a template header:

    template <typename T> friend class X<T>;
Date: 2008-06-15.00:00:00

Proposed resolution (June, 2008):

Change 11.8.4 [class.friend] paragraph 3 as follows:

A friend declaration that does not declare a function shall have one of the following forms:

    friend elaborated-type-specifier ;

    friend simple-type-specifier ;

    friend typename-specifier ;

    friend ::opt nested-name-specifieropt template-name ;

    friend identifier ;

In the last alternative, the identifier shall name a template template-parameter. [Note: a friend declaration may be the declaration in a template-declaration (Clause 13 [temp], 13.7.5 [temp.friend]). —end note] If the type specifier in a friend declaration designates a (possibly cv-qualified) class type or a class template, that class or template is declared as a friend; otherwise, the friend declaration is ignored. [Example:...

Date: 2006-06-15.00:00:00

After the adoption of the wording for extended friend declarations, we now have this new paragraph in 11.8.4 [class.friend]:

A friend declaration that does not declare a function shall have one of the following forms:

    friend elaborated-type-specifier ;
    friend simple-type-specifier ;
    friend typename-specifier ;

But what about friend class templates? Should the following examples compile in C++0x?

    template< template <class> class T >
         struct A{ friend T; };

    template< class > struct C;
    struct B{ friend C; };
History
Date User Action Args
2008-10-05 00:00:00adminsetmessages: + msg1834
2008-10-05 00:00:00adminsetstatus: review -> nad
2008-06-29 00:00:00adminsetmessages: + msg1683
2008-06-29 00:00:00adminsetstatus: drafting -> review
2006-11-05 00:00:00adminsetstatus: open -> drafting
2006-06-15 00:00:00admincreate