Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the meaning of the highlighted sentence below in [over.load]/1?

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 ]

like image 681
Alexander Avatar asked Jul 15 '19 14:07

Alexander


1 Answers

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.

like image 197
Rakete1111 Avatar answered Nov 15 '22 13:11

Rakete1111