Function call not ambiguous if {} is used
Why is
{}
implicitly converted toint
?
This is copy-list-initialization, as the effect the parameter is value-initialized (zero-initialized) as 0
. int
could be initialized from (empty) braced-init-list, just as int i{};
or int i = {};
.
- in a function call expression, with braced-init-list used as an argument and list-initialization initializes the function parameter
For f(std::vector<int>)
and f(std::deque<int>)
to be called, a user-defined conversion (by the constructor of std::vector
and std::deque
taking std::initializer_list
) is required; then the 1st overload wins in overload resolution.