4 ms·
You can still freely access global variables inside lambdas, with or without captures.
by pbsd 10y ago
You can still freely access global variables inside lambdas, with or without captures.
- hellofunk 10y agoThanks for clarification. I thought the capture list was required for this. I suppose the capture list is for capturing variables that are local to the scope of the lambda's definition.
- hellofunk 10y agoI have been testing this, and I'm not convinced. A lambda with no capture at all (just []) will not compile if it accesses any variable in the scope of the lambda definition (including globals). I must add [=] or similar to get access to them. What were you referring to? The compiler error is clear: "variable 'lam' cannot be implicitly captured in a lambda with no capture-default specified"