Created
February 22, 2016 20:20
-
-
Save meshell/10fa15b1f9603de70f13 to your computer and use it in GitHub Desktop.
Smart_Pointers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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