vendredi 27 février 2015

VC2013 move operator doesn't recursively perform move


The following code doesn't compile in VS2013.



#include <memory>
#include <vector>

struct Struct {
std::unique_ptr<int> data;
};

int main() {
std::vector<Struct> vec;
vec.emplace_back();
vec.emplace_back();
vec.front() = std::move(vec.back());
return 0;
}


I get the following error:



error C2280: attempting to reference a deleted function


It seems like VS compiler is trying to call the assignment operator while the code explicitly requests a move. Is this a bug? Are there any workarounds for this problem?




Aucun commentaire:

Enregistrer un commentaire