is auto type detection only looking at one statement

  auto, c++, c++11

For the two for loop below, are they equivalent? Basically does the auto look over "=0" assignment and see iter is compared with s.size() and so decides iter is of type decltype(s.size())?

string s;
for(auto iter=0; iter<s.size();iter++)

string s;
for(decltype(s.size()) iter=0; iter<s.size();iter++)

Source: Windows Questions C++

LEAVE A COMMENT