In an example with vector<int> someVector and istringstream someStringStream you can do this:
for (int i=0; i < someVector.size(); i++) {
someStringStream >> someVector[i];
}
I know that vector<bool> is an efficient implementation, and operator[] returns a reference object. For this code I should be using an index rather than an iterator, mostly for readability. Currently, I'm using this:
for (int i=0; i < someVector.size(); i++) {
bool temp;
someStringStream >> temp;
someVector[i] = temp;
}
Is there a more direct way of implementing this?
Aucun commentaire:
Enregistrer un commentaire