4

I've got the following code :

#include <functional>

using namespace std;

void foo(function<void(int)>);
void foo(function<void(float, int)>);


void bar(int);
void bar2(float, int);

void dummy()
{
    foo(bar);
    foo(bar2);
}

Depending on the different compilers I tried on http://gcc.godbolt.org/ there is an ambiguity error or not... Who's right ? What is the most elegant way to solve this issue ?

RTempete
  • 245
  • 1
  • 4
  • 1
    This doesn't compile, it is not a complete example that reproduces your problem. – tillaert Jun 25 '14 at 08:13
  • 3
    http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3473.html#2132 – Simple Jun 25 '14 at 08:13
  • 2
    @tillaert it is a complete example. The fact it doesn't compile is his problem. – Simple Jun 25 '14 at 08:16
  • This is supposed to be ambiguous in C++11. I think the compilers that succesfully compile the code are applying C++14 rules where the constructor `template std::function(F);` doesn't participate in overload resolution if `F` is not callable with the signature of `std::function` that's being constructed. – jrok Jun 25 '14 at 08:21

0 Answers0