3 ms·
Not sure I get your point - the exact same is true of a C function which is passed a void* ctx object, since those objects have to be allocated and their lifecy
by zozbot234 5y ago
Not sure I get your point - the exact same is true of a C function which is passed a void* ctx object, since those objects have to be allocated and their lifecycle has to be managed. It's still a zero overhead feature.
- Koshkin 5y agoThe (potential) overhead lies with 'ctx' of course. The lambda syntax makes it all too easy to forget about it.
- ncmncm 5y agoA pointer argument passed in a register is not what we mean when we say "overhead". Without the lambda, you would instead need to pass the pointer manually, for identically the same cost. But then the compiler would not understand as well what you were doing, and would be unable to optimize it as well. Here, the lambda gives you negative overhead, vs. what you would have written.
- Koshkin 5y agoYou have to look beyond the pointer, of course. (An object and a pointer to it, ‘this’, are two different things.)