Why destructor of a moved from object is invoked?
问题 Consider the following piece of code: struct foo { std::string id; }; int main() { std::vector<foo> v; { foo tmp; v.push_back(std::move(tmp)); } } LIVE DEMO In the piece of code demonstrated: The default constructor of class foo is going to be invoked for the construction of object tmp . The move constructor of class foo is going to be invoked in the statement v.push_back(std::move(tmp)); . The destructor of class foo is going to be invoked twice. Questions: Why the destructor of a moved from