Recently on SO:
Why does C++ not allow multiple types in one auto statement?
The 2011 C++ standard introduced the new keyword
auto
, which can be used for defining variables instead of a type, i.e.auto p=make_pair(1,2.5); // pair<int,double> auto i=std::begin(c), end=std::end(c); // decltype(std::begin(c))In the second line,
i
andend
are of the same type, referred to asauto
. The standard does not allowauto i=std::begin(container), e=std::end(container), x=*i;when
x
would be of different type. My question: why does the standard not allow this last line? ...
Add a Comment
Comments are closed.