Skip to content

Instantly share code, notes, and snippets.

@RklAlx
Created September 27, 2013 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RklAlx/6727558 to your computer and use it in GitHub Desktop.
Save RklAlx/6727558 to your computer and use it in GitHub Desktop.
std::shared_ptr
std::shared_ptr<int> p1(new int(5));
std::shared_ptr<int> p2 = p1; //Both now own the memory.
p1.reset(); //Memory still exists, due to p2.
p2.reset(); //Deletes the memory, since no one else owns the memory.
int value = p1.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment