#include #include #include int main() { std::vector > funcs; for (int i = 0; i < 10; i++) funcs.push_back([=]() { return i * i; }); for ( std::function f : funcs ) std::cout << f( ) << std::endl ; return 0; }