What is the meaning of the highlighted sentence below? Does it have anything to do with function templates?
[over.load]/1:
Not all function declarations can be overloaded. Those that cannot be overloaded are specified here. A program is ill-formed if it contains two such non-overloadable declarations in the same scope. [ Note: This restriction applies to explicit declarations in a scope, and between such declarations and declarations made through a using-declaration ([namespace.udecl]). It does not apply to sets of functions fabricated as a result of name lookup (e.g., because of using-directives) or overload resolution (e.g., for operator functions). — end note ]
You can do something like this:
namespace N {
void f(int);
}
namespace M {
int f(int);
}
using namespace N; // ok
using namespace M; // ok
// even if both have conflicting f's
You aren't directly overloading anything here. The using directives allow name lookup to find both functions and it's at that point that the call is ambiguous.
Here the sets of functions contain two non-overloadable are in there, but since they are found by name lookup as per the quote, they're okay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With