In C ++ 11, you can use std::vector::push_back in combination with std::move to avoid copying when inserting elements into a vector. Is there a section in the standard that prohibits compilers from using std::move automatically with local variables that are not used after calls to push_back ? When filling vectors with large elements, this can be a huge advantage.
I checked the following code with gcc 7.1.0 and -O3 , and with version 1 it prints move , and version 2 prints copy .
#include <iostream>
source share