Skip to content

Instantly share code, notes, and snippets.

@leedm777
Created June 22, 2012 19:42
Show Gist options
  • Save leedm777/2974685 to your computer and use it in GitHub Desktop.
Save leedm777/2974685 to your computer and use it in GitHub Desktop.
tap implementation for C++11
/** tap implementation for C++11 */
template<typename T, typename F>
T tap(T &&obj, F const &fn) {
fn(obj);
return obj;
}
// usage
tap(new User(params), [](User *u) {
if (u->isValid()) {
userMailer.deliverWelcomeEmail(*u);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment