Closing is a function that captures data from the environment in which it was declared.
int myVar = 0; auto foo = [&] () { myVar++; }; <- This lambda forms a closure by capturing myVar foo(); assert(myVar == 1);
Continuation is a more abstract concept and relates to what code should be executed subsequently. It can be implemented using closure.
myTask = Task([] () { something(); }); myTask.then([=] () { myFoo.bar(); }); // This closure is the continuation of the task myTask.run();
source share