Created
May 26, 2020 23:10
-
-
Save mklca/98af8be39ebf91e822f89bd83f6cd43b to your computer and use it in GitHub Desktop.
Attempting to build a call-at-most-once functor
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
#include <iostream> | |
#include <utility> | |
using namespace std; | |
struct F { | |
F() = default; | |
F(const F&) = delete; | |
F& operator =(const F&) = delete; | |
void operator()() && { | |
cout << "In (F&&)()\n"; | |
} | |
}; | |
int main() { | |
F f; | |
// f(); error: No matching function for call to object of type 'F' | |
move(f)(); | |
move(f)(); // Clang-Tidy: 'f' used after it was moved | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment