#include <functional>
#include <iostream>
using namespace std;

const function<void()>* pointer;

void a(const function<void()> & f)
{
    pointer = &f;
}

void b()
{
    (*pointer)();
}

int main()
{
    int value = 1;
    std::cout << value << std::endl;

    // 1: this works    
    function<void()> f = [&] () { std::cout << value << std::endl; };
    a(f);

    // 2: this doesn't
    a([&] () { std::cout << value << std::endl; });
    //c();
    char data[1024];
    for (int i = 0; i < 1024; i++)
        data[i] = i % 4; 

    b();

    return 0;
}