Last active
January 25, 2020 08:44
-
-
Save kalman5/30b8d00f3f56a6eb7cc2be187dd0ef5d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct Foo { | |
// used when Foo instance is an l-value | |
void operator()() const & { | |
std::cout << "l-value" << "\n"; | |
} | |
// used when Foo isntance is an r-value | |
void operator()() const && { | |
std::cout << "r-value" << "\n"; | |
} | |
}; | |
Foo f; | |
f(); // First operator is used | |
Foo()(); // Second operator is used |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment