Created on 2008-02-07.00:00:00 last changed 130 months ago
[Voted into WP at August, 2010 meeting.]
Proposed resolution (June, 2010):
Change 13.7.5 [temp.friend] bullet 1.3 as follows:
...For a friend function declaration that is not a template declaration:
...
if the name of the friend is a qualified-id and a matching
specialization of afunction template is found in the specified class or namespace, the friend declaration refers tothat function template specializationthe deduced specialization of that function template (14.8.2.6 [temp.deduct.decl]), otherwise,...
(This resolution depends on that of issue 873; in particular, the cross-reference to 14.8.2.6 [temp.deduct.decl] refers to a new section added by the resolution of that issue.)
13.7.5 [temp.friend] bullet 1.3 says:
if the name of the friend is a qualified-id and a matching specialization of a function template is found in the specified class or namespace, the friend declaration refers to that function template specialization, otherwise,
I'm not sure this says what it's supposed to say. For example:
namespace N { template<class T> int f(T); } class A { friend int N::f(int); int m; A(); }; namespace N { template< class T > int f(T) { A a; // ok for T=int? return a.m; // ok for T=int? } } int m = N::f(42); // ok? char c = N::f('a'); // Clearly ill-formed.
The key is that the wording talks about a “matching specialization,” which to me means that N::f<int> is befriended only if that specialization existed in N before the friend declaration. So it's ill-formed as written, but if we move the call to N::f<int> up to a point before the definition of A, it's well-formed.
That seems surprising, especially given that the first bullet does not require a pre-existing specialization. So I suggest replacing bullet 3 with something like:
if the name of the friend is a qualified-id and a matching function template is found in the specified class or namespace, the friend declaration refers to the deduced specialization of that function template, otherwise,
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | status: wp -> fdis |
2010-11-29 00:00:00 | admin | set | status: dr -> wp |
2010-08-23 00:00:00 | admin | set | status: review -> dr |
2010-03-29 00:00:00 | admin | set | messages: + msg2575 |
2010-02-16 00:00:00 | admin | set | messages: + msg2556 |
2010-02-16 00:00:00 | admin | set | status: drafting -> review |
2008-06-29 00:00:00 | admin | set | status: open -> drafting |
2008-02-07 00:00:00 | admin | create |