I was reading the following code sample:
std::array<int, 4> parseMessage(const std::string& input) {
std::stringstream ss(input);
std::array<int, 4> message;
int n;
// Loop over all characters in the string and ignore the semicolons.
for (int i = 0; ss >> n && i < 4; ++i) {
message[i] = n;
if (ss.peek() == ';') {
ss.ignore();
}
}
return message;
}
Can someone explain why someone would do ss>>n in the loop condition area ? It looks a bit odd to me.