Skip to content

Instantly share code, notes, and snippets.

@George3d6
Last active September 18, 2018 21:16
Show Gist options
  • Save George3d6/7eab247c8869a367395be144e2551580 to your computer and use it in GitHub Desktop.
Save George3d6/7eab247c8869a367395be144e2551580 to your computer and use it in GitHub Desktop.
//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