There is a special, very surprising rule (but this does not apply to your example), stating that after searching for a class name by searching by name, namespace areas are not visible:
#include <string> struct C { std::string s; explicit C (std::string); void swap (C& rhs) { swap (s, rhs.s); // error: swap is C::swap } }; void swap (C& lhs, C& rhs) { swap (lhs.s, rhs.s); // std::swap(string,string) }
IMO, this is crazy.
But why forbid unambiguous calls, where a free function has a different signature:
The name search occurs before permission is overloaded:
- If the search is ambiguous, permission overload is not performed.
- If no viable function is found when searching by name, no other search rounds are checked.
The rules are quite complex without the โfeedbackโ between overloading and finding names. I would suggest simplification (for example, removing the namespace name list rule for hidden element names and removing the ambiguous name lookup) rather than complexification.
curiousguy
source share