Your original post keeps changing! And I can't actually see why you would want to do this with a lambda function anyway: you might as well just declare the array in situ.
However ...
1 2 3 4 5 6 7 8 9
#include <iostream>
#include <vector>
usingnamespace std;
int main()
{
auto fn = [](){ return vector<int>{ 0, 4, 9 }; };
for ( auto e : fn() ) cout << e << ' ';
}
You can also do the following ... but I don't recommend it.
1 2 3 4 5 6 7 8 9 10
#include <iostream>
usingnamespace std;
int main()
{
auto fn = [](){ returnnewint[3]{ 0, 4, 9 }; };
int *p = fn();
for ( int i = 0; i < 3; i++ ) cout << p[i] << ' ';
delete [] p;
}