'Lambda functions with "=" capture and memory usage
In my mind when I create a lambda [=]{...} all variables from parent function clones to the lambda.
So the following code will use too much memory because variables a...z will be copied to lambda function:
void foo() {
long double a = 0.123456789;
long double b = 0.123456789;
long double c = 0.123456789;
//....
long double z = 0.123456789;
auto val = [=]() {return a+z;};
}
Is not it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
