std::vector<std::string> container;
// Add 100000 strings to container
std::vector<std::string>::iterator it = container.begin()
while (it != container.end()) {
std::string str = *it;
// do something with str
it++;
}
or
int size = container.size();
for (int i=0; i< size; i++) {
std::string str = container[i];
// do something with str
}
On this page:
there are some different opinions, but what are your experinces?
In my experience, those things are compiler-specific, system-specific,
and cannot be theorised upon. They need to be measured.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
I think that "different opinions" is the correct result :-)
It varies some, but the difference is VERY small. The "do something
with str" is highly likely to dominate the timing anyway.
Bo Persson