F.53: Minor fix.

This commit is contained in:
psliwa 2016-02-04 11:05:16 +01:00
parent 4fc0beafc3
commit fdd91e959a

View File

@ -3152,18 +3152,20 @@ Pointers and references to locals shouldn't outlive their scope. Lambdas that ca
##### Example, bad ##### Example, bad
{ {
int local_variable = 42; int local = 42;
background_thread.queue_work([&]{ process(local_variable); }); // Want a reference to local_variable. thread_pool.queue_work([&]{ process(local); }); // Want a reference to local.
// Note, that after program exists this scope, local_variable does no longer exist, // Note, that after program exists this scope,
// therefore process() call will have undefined behavior! // local does no longer exist,
// therefore process() call will have undefined behavior!
} }
##### Example, good ##### Example, good
{ {
int local_variable = 42; int local = 42;
background_thread.queue_work([=]{ process(local_variable); }); // Want a copy of local_variable. thread_pool.queue_work([=]{ process(local); }); // Want a copy of local.
// Since a copy of local_variable is made, it will be available at all times for the call. // Since a copy of local is made, it will be
// available at all times for the call.
} }
##### Enforcement ##### Enforcement