Skip to content

Instantly share code, notes, and snippets.

@jdsgomes
Last active August 22, 2016 09:50
Show Gist options
  • Save jdsgomes/7e10010284f017208bfdfeedcd76b3ed to your computer and use it in GitHub Desktop.
Save jdsgomes/7e10010284f017208bfdfeedcd76b3ed to your computer and use it in GitHub Desktop.
C++

C++

C++11 smart pointers

  • shared_ptr
    • Raw pointer can be co-own by several shared pointers and a reference count is kept. Memory is realeased when the reference count is 0.
  • unique_ptr
    • Raw pointer can be own by only one unique pointer. No assignments or copies can be made. No need to keep a reference count, memory is released when the pointer is out of scope.
  • weak_ptr
    • Does not grant acess to the pointed data, is a view only pointer which can be used to query the status of the pointed date (if it still exists or not) and to create a shared pointer from it.

STL

STL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment