Topic: Let qualified lookup find associated friends in named namespace


Author: David Krauss <potswa@gmail.com>
Date: Wed, 11 Jun 2014 12:17:01 +0800
Raw View
A friend function which cannot be declared as a non-friend can only be foun=
d by ADL. Adding a nested-name-specifier to the function name disables ADL =
and prevents the function from being found.

Lookup is intricate to be sure, and I've written code that depends on names=
pace qualification disabling ADL. But, I can't imagine needing to remove AD=
L-only friends from the overload set.

The case where it makes the biggest difference is in calling a function wit=
h explicit template arguments. The template argument list will only parse i=
nto a template-id if a template declaration is found for the potential temp=
late-name. This leaves the user with two options: declare a bogus template =
in the local namespace, or qualify the name. The first option is heinous, b=
ut the second doesn't work for friends, even if the library declares a bogu=
s overload in its own namespace. Splitting the difference, the user can add=
 a using declaration for the library's bogus template, but that still sucks=
..

GCC simplifies this for users by not hiding friend function templates at al=
l. Non-template friend functions and class templates are hidden, though, so=
 as a bug it's suspiciously specific.

What do folks think of letting ADL work its magic on namespace-qualified fu=
nction names, within the given namespace? Although the problem sounds obscu=
re, I suspect that the practice of qualifying a friend's name may be what's=
 blocking GCC's conformance in this regard, which may be interpreted as an =
indication that the standard is at odds with industry practice.

I'm CC'ing Daniel Kr=FCgler for some opinion or confirmation regarding GCC'=
s dialect... maybe it's just an ordinary pesky bug. Anyway, it would be nic=
e to see this convenience supported by the standard.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.