3 ms·
That's a good point, but when I think of the typical code for non-range-based for loop it looks like: for (vector<string>::iterator i = data.begin(); i !=
by minimax 13y ago
That's a good point, but when I think of the typical code for non-range-based for loop it looks like:
for (vector<string>::iterator i = data.begin(); i != data.end(); ++i) {
ofile << *i << std::endl;
}
which makes it pretty clear what types we're dealing with.
- marshray 13y agoI think in C++1y we'll be able to define a function 'foreach' that we can use like: foreach(data, []<class T>(const T & item) { ofile << item << std::endl; }); This should eliminate the potential implicit conversion to temp. But I'm not sure it's seriously better than the original range based for with auto.