C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: C++ 20, Unqualified name look: a confusing relative to postfix expressions.
From: Andrew Schepler (aschepler_at_[hidden])
Date: 2019-09-04 16:46:15


> It would thus seem that [class.friend]/7 should be deleted or should be changed to a note (possibly reworded).

I agree.

Though is it worth clarifying somewhere that non-definition
declarations of the function follow the same rules? I mean, in a
friend declaration which declares a function or function template,
names in the return type, parameter list, exception specification, and
any template parameters and default template arguments are looked up
"in class scope", but for any other declaration of the same function
or function template, those names are looked up using the usual rules
starting with that declaration's enclosing declarative region. (The
rule about using scope lookup for names after the declarator of a
class member's definition outside the class definition doesn't apply
since a friend function isn't really a class member.)

For that matter, the same is true for non-function friend
declarations, like in the template parameter list of a friend
declaration of a class template, or in qualified names, decltype()
syntax, and template arguments of a template-id when befriending just
a single type. Would [basic.lookup.unqual]/9 be better if it talked
about "a name in a friend declaration" rather than "a name used in the
definition of a friend function defined inline in the class" and
"other declarations of the same entity" instead of "if the friend
function is not defined in the class"? Or can we take that as normally
covered by the usual lookup rules, and the purpose of
[basic.lookup.unqual]/9 is to make it clear the rule about member
definitions outside class definitions does not apply to friends?

-- Andrew Schepler


STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups