#include <iostream>
template < typename T>
void bar( T t) { } ;
int main( ) {
//foo's type would be deduced as std::initializer_list<int>
auto foo = { 0 , 1 , 2 , 3 } ;
//compiles fine
bar( foo ) ;
//next line gives compiler error
foo( { 0 , 1 , 2 , 3 } ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8dHlwZW5hbWUgVD4gCnZvaWQgYmFyKFQgdCl7fTsKCQppbnQgbWFpbigpIHsKCS8vZm9vJ3MgdHlwZSB3b3VsZCBiZSBkZWR1Y2VkIGFzIHN0ZDo6aW5pdGlhbGl6ZXJfbGlzdDxpbnQ+CglhdXRvIGZvbyA9IHswLCAxLCAyLCAzfTsgCgoKCgkvL2NvbXBpbGVzIGZpbmUKCWJhciggZm9vICk7CgkKCS8vbmV4dCBsaW5lIGdpdmVzIGNvbXBpbGVyIGVycm9yCglmb28oezAsIDEsIDIsIDN9KTsKCQoJcmV0dXJuIDA7Cn0=
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:18: error: no match for call to '(std::initializer_list<int>) (<brace-enclosed initializer list>)'
foo({0, 1, 2, 3});
^
stdout