When I read std::function, I find the following syntax confusing. What does a struct followed directly by empty parentheses do here? It works equivalent to declare a struct object instead and call its operator.
#include <iostream>
using namespace std;
int main() {
struct F {
bool operator()(int a) {
return a>0;
}
};
function<bool(int)> f = F(); //What does the syntax F() mean here?
struct F ff;
cout << f(1) <<endl;
cout << ff(1) <<endl;
return 0;
}