fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <memory>
  4.  
  5. struct State {
  6. State() { std::cout << "constructor" << std::endl; }
  7. ~State() { std::cout << "destructor" << std::endl; }
  8. };
  9.  
  10. int main() {
  11. std::vector< std::unique_ptr<State> > mStates;
  12. mStates.push_back(std::unique_ptr<State>(new State{}));
  13. mStates.pop_back();
  14. std::cout << "done" << std::endl;
  15. }
  16.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
constructor
destructor
done