This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


21. Can a default argument for a template parameter appear in a friend declaration?

Section: 13.2  [temp.param]     Status: TC1     Submitter: unknown     Date: unknown

13.2 [temp.param] paragraph 10 says:

The set of default template-arguments available for use with a template declaration or definition is obtained by merging the default arguments from the definition (if in scope) and all declarations in scope in the same way as default function arguments are (9.3.4.7 [dcl.fct.default] )."
Can a default argument for a template argument appear in a friend declaration? If so, when is this default argument considered for template instantiations?

For example,

    template<class T1, class T2 = int> class A;

    class B {
        template<class T1 = int, class T2> friend class A;
    };
Is this well-formed? If it is, should the IS say when the default argument for T1 is considered for instantiations of class A?

Proposed resolution (10/00): Add to the end of 13.2 [temp.param] paragraph 9,

A default template-argument shall not be specified in a friend template declaration.

(See also issue 136.)