WARNING - pure hypotheticals, may be waste of time unless you're interested
in what's under the hood of various nifty C++11 implementations
You are right. But then, what's the meaning of sizeof lambda ? 1-byte ?
Here is a piece of nonsense code :
#include <iostream>
using namespace std;
int main()
{
auto lambda=[](){ return nullptr;};
auto next_lambda=[](){ return 1; };
cout << sizeof lambda << endl;
// auto lambda_size = sizeof [](){return nullptr;}; // Does not compile with
it's own error, as promised
auto plambda = &next_lambda;
void *pointer= plambda;
int *clambda ;
clambda = (int*)pointer;
cout << *clambda << endl;
return 0;
}
It compiles fine, when ran it either outputs 1\n0\n (Solaris Studio 12.4
Sparc, 32-bit target) or dumps core with Bus error (memory alignment) (gcc
and 64-bit SUNWspro 12.4) - IMGO more appropriate response - when
dereferencing clambda.
So basically, lambda is 1-byte memory location containing a zero (always a
zero, in practice). For some reason, I was expecting something resembling a
vtable. Does this mean that lambda semantics and implementation are
something purely compile-time and thin ?
"Victor Bazarov" wrote in message news:lvfpbr$a4j$1...@dont-email.me...