Skip to content

Instantly share code, notes, and snippets.

@meshell
Created February 22, 2016 20:20
Show Gist options
  • Save meshell/10fa15b1f9603de70f13 to your computer and use it in GitHub Desktop.
Save meshell/10fa15b1f9603de70f13 to your computer and use it in GitHub Desktop.
Smart_Pointers
// unique object ownership
auto unique = std::unique_ptr<widget>(new widget());
auto unique = std::make_unique<widget>();
// shared object ownership
auto shared = std::make_shared<widget>();
// weak reference to an object managed by std::shared_ptr
std::weak_ptr<widget> weak = shared;
auto shared_tmp = weak.lock();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment