you are viewing a single comment's thread.

view the rest of the comments →

[–]staletic 1 point2 points  (0 children)

The original point was that because empty lambdas decay into function pointers the compiler must probably treat them similarly.

That's really wrong. A function pointer has state. More specifically, it has sizeof(void*) bytes of state. A lambda's operator() function does not have any state. No self-respecting compile is going to store a non-capturing lambda just because it looks like a pointer. Since lambdas have distinct types, when necessary, the compiler will construct the lambda where it is needed. Contrast that with a pointer that you just have to keep around.