I want to append a vector to the end of another vector. According to my knowledge, the function std::move() is the "function of choice" for this task. Why is std::move() from Microsoft Visual C++ Express crashing while a hand-crafted loop works as expected?
I am using Microsoft Visual C++ 2015 Update 3. Unfortunately I'm not able to test this with other compilers.
// The setup code for the two vectors:
vector<unique_ptr<channel>> channels, added_channels;
// ... here is some code that adds some elements to both vectors
According to my knowledge the following two pieces of code should work the same way. They should move the elements of added_channels to the end of channels.
This is the first variant that crashes:
std::move(added_channels.begin(), added_channels.end(), channels.end());
This is the second version that works:
for(auto & ref : added_channels)
{
channels.push_back(std::move(ref));
}
Aucun commentaire:
Enregistrer un commentaire