Last active
September 18, 2018 21:16
-
-
Save George3d6/7eab247c8869a367395be144e2551580 to your computer and use it in GitHub Desktop.
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
//Return a unique pointer,meaning we have sole ownership of the widget | |
unique_ptr get_widget(); | |
void use_widget() { | |
//Thus we don't need to Lock it to call its methods | |
//We can move the unique_ptr to function after we are done with it | |
//Or just forget about it and it shall free the underlying ressource | |
auto widget_ptr = get_widget(); | |
if(widget_ptr->get_status() == 42) | |
widget_ptr->trigger_event(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment