samedi 28 février 2015

unique_ptr with standard containers: attempting to reference a deleted function

I'm trying to use unique_ptr with any stl container (actually list is prefer for me), I see that unique_ptr requires move semantics . this code where employee is a base class:



typedef std::unique_ptr<employee> p_employee;

std::list<p_employee> make_test_array() {
std::list<p_employee> objects = {
p_employee(new accounter(...)),
p_employee(new engineer(...)),
p_employee(new developer(...))
};

return objects;
}


you see what I'm trying to do - just a return this list from a function


so is there ability to do this? what is a right technique?


Aucun commentaire:

Enregistrer un commentaire