fork download
  1.  
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. struct Object {
  6. Object() { printf("ctor\n"); }
  7. Object(const Object&) { printf("copy ctor\n"); }
  8. Object& operator=(const Object&) { printf("copy assign\n"); return *this; }
  9. Object(Object&&) { printf("move ctor\n"); }
  10. Object& operator=(Object&&) { printf("move assign\n"); return *this; }
  11. };
  12.  
  13. int main() {
  14. std::vector<Object> v{};
  15.  
  16. v.push_back(Object{});
  17.  
  18. printf("second element\n");
  19.  
  20. v.push_back(Object{});
  21. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
ctor
move ctor
second element
ctor
move ctor
copy ctor