jeudi 31 mars 2016

How to generate vector like list comprehension

In C++11,

vector<string> blockPathList;
for(int i = 0; i < blockNum; i++)
{
    blockPathList.push_back(desPath + "part" + to_string(i));
}

Is it possible to re-write the code above like list comprehension, or shorter and more concise?

Aucun commentaire:

Enregistrer un commentaire