mercredi 25 novembre 2015

rename variables in the middle of the scope

I want to change a variable name in middle of its scope for readability issue.

For example:

while(condition){
    std::vector<big_type> all_things;
    //some operation like pop_back is happing on all_things
    //now all_things contains just the good_things
    auto& good_things=all_things;
    //do some operation on good_things which is actually on all_things
}

I am doing this because I can not afford copying this vector.

Is this the right way to do it? I am afraid now that my will to make it more readable resulted in less readability. Any other suggestions?

Aucun commentaire:

Enregistrer un commentaire