This is a rather general question. In this post Where does a std::vector allocate its memory? it says that vector allocates its elements in the heap by default. In C++11, there is move semantics and vector supports this. What if I have an object which has only move constructor, and I have declared this object in the stack, now I want to push_back this object into a vector, is the one being pushed back still in the heap? An example might be pushing back a stack declared std::thread t1(someFunc) into a vector.
mercredi 13 mai 2015
push back an object which has only move constructor to a vector
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire