fork download
  1. #include <iostream>
  2. #include <memory>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. struct A {
  8. std::string Name;
  9.  
  10. ~A() {
  11. std::cout << "Wut" << std::endl;
  12. }
  13.  
  14. };
  15.  
  16. int main() {
  17.  
  18. std::vector<std::unique_ptr<A>> vector_of_as;
  19. {
  20. std::unique_ptr<A> new_a(new A());
  21. vector_of_as.push_back(std::move(new_a));
  22. }
  23. vector_of_as.back()->Name="Should Work";
  24. std::cout << "Name: " << vector_of_as.back()->Name << std::endl;
  25.  
  26. return 0;
  27.  
  28. }
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
Name: Should Work
Wut