Skip to content

Instantly share code, notes, and snippets.

@jbeardson
jbeardson / TestLocalsCapture.cpp
Last active May 26, 2018 11:48
C++ vs Delphi capture of local variables
#include <iostream>
#include <functional>
#include <vector>
int main() {
std::vector<std::function<void()>> vfn;
for(int i = 0; i < 10; ++i) {
vfn.push_back([i]() { std::cout << i << std::endl; });
}