fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. struct stype
  8. {
  9. stype(stype&& s):ptr(s.ptr) { s.ptr = 0; cout << "stype(const stype&&)\n"; }
  10. stype(const stype& s):ptr(s.ptr) { cout << "stype(const stype&)\n"; }
  11. ~stype(){ cout << "~stype()\n"; }
  12. void* ptr;
  13. template<typename T>
  14. stype(T v) { ptr = new T(v); cout << "stype(" << v << ")\n"; }
  15. };
  16.  
  17. int main(int argc, const char * argv[])
  18. {
  19. vector<stype> v;
  20. v.emplace_back(5);
  21. }
  22.  
  23.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
stype(5)
~stype()