jeudi 2 juillet 2015

Replace the content of container with data from another container

The design of the code is something like that:

std::list<std::string> core_data;
...<filling this list up during the application workflow
....


while (<some condition>) {
    std::list<std::string> temp_data;
    //... <some logic to build temp_data 
    // ... based on the elements from core_data 
    // ...
    // replace core_data with temp_data for next iteration
    // in this point core_data is already empty
    core_data = temp_data;
}

What is a mostly effective way to assign core_data with temp_data?

Is this way correct? More effective?

core_data = std::move(temp_data);

Aucun commentaire:

Enregistrer un commentaire