#include <stdio.h>
#include <vector>
#include <deque>
// 1st function
void f(int i, int j = 10){
printf("Hello World what");
};
void f(std::vector<int>){
printf("Hello World vec");
};
void f(std::deque<int>){
printf("Hello World deq");
};
int main()
{
f({});
return 0;
}
If the 1st function is commented out I get ambiguous call
when compiling. If not commented out, 1st function is called. Why is {}
implicitly converted to int
?
Live example: https://onlinegdb.com/rkhR0NiBD
initializer_list
constructors are not explicit. In fact, they both match, hence the ambiguity. – Tshombe