mercredi 4 mars 2015

How does std::begin deduce a type for braced-init-list?

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?


Aucun commentaire:

Enregistrer un commentaire