I was experimenting with lambdas and compilers because of another question here on SO.
I've just realized (and it's perfectly normal indeed) that the following code is valid:
int main() {
auto l = [](){};
l.operator()();
}
Actually the standard says that the closure type has a public inline function call operator and so on, thus it makes sense to be able to invoke it.
What I can't explain by looking at the standard (well, the working draft) is the fact that GCC (6.1) compiles the following snippet (clang 3.9 does not):
int main() {
auto l = []<typename>(){};
l.operator()<void>();
}
No warnings, no errors. Is it valid code or should it be rejected by the compiler?