Std :: function overload ambiguity

I have 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/ , is there an ambiguity error or not ... Who is right? What is the most elegant way to solve this problem?

+4
source share

Source: https://habr.com/ru/post/1545951/


All Articles