Reputation: 43
The following code fails:
template <typename T>
void func(T& t)
{
}
int main()
{
func({1, 2, 3});
}
But with auto a = {1, 2, 3};
it works because the rules allow auto
to deduce an std::initializer_list
. How is std::begin
written to allow std::begin({1, 2, 3})
to work?
Upvotes: 4
Views: 135
Reputation: 42858
std::begin({1, 2, 3})
works because std::begin
has an overload taking an std::initializer_list
.
Upvotes: 7