How to reset candidates for overload functions?

How can I reset candidate functions (or viable functions or most efficient functions) to call a function?

I know that g ++ provides an option to reset the class hierarchy . (Actually, Visual Studio 2010 provides a similar option, but it is undocumented. I remember that I read something about it - maybe in the blog of the VC ++ team, but I can’t remember it.)

I recently read about overload resolution in a C ++ 0x draft, and that really confused me.

Does any compiler provide the ability to reset candidate functions, viable functions, or the most efficient functions?

Note. The candidate functions in the overload resolution script are different from the candidate functions in the compiler error. The candidate / viable / best viable function in the overload resolution scenario is relevant. I know that there are three stages to resolving overload: find the functions of the candidate; find viable functions; find the best viable features. As a rule, only one candidate is the best viable function; otherwise the call is ambiguous. Each stage has its own rules.

+5
source share
3 answers

I do not think there is a direct path.

- / . , .

namespace A {
    void f(int x) {}
}
void f(int x) {}
void f(char x) {}

using namespace A;

int main(){
    f(2.2);
}

g++:

prog.cpp: In function β€˜int main()’:
prog.cpp:10: error: call of overloaded β€˜f(double)’ is ambiguous 
prog.cpp:4: note: candidates are: void f(int)
prog.cpp:5: note:                 void f(char) 
prog.cpp:2: note:                 void A::f(int)
+2

, , - , :

struct DumpThemAll {};

int main(int argc, char* argv[])
{
  std::cout << DumpThemAll() << std::endl;
}

() operator<<, . .

, . - , , , , "", ... ​​, , ( ... ...)

, , , , , , , , , , .

, / (, , ).

+2

The easiest way to do this in Visual Studio is to make an ambiguous call. The compiler will spit out an error with a list of available candidates. G ++ will probably do the same.

+1
source

All Articles