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?
std::begin({1, 2, 3})
works because std::begin
has an overload taking an std::initializer_list
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With