vector.push_back rvalue and copy-elision
问题 I push_back a temporary object into a vector like this, vector<A> vec; vec.push_back(A("abc")); will the compiler apply copy-elision to construct the temporary A("abc") directly into the vector , so that A 's copy ctor won't be triggered when pushing the temporary object into vec . 回答1: If you have a compiler that supports rvalue references, it will be moved into the vector, which is sometimes quite cheap. An alternative to that is to directly construct the object in the vector, which can be