I was trying to create a vector of
lambda, but failed:
auto ignore =
[&]() { return 10; }; //1
std::vector v;
//2
v.push_back([&]() { return 100; });
//3
Up to line #2, it
compiles fine. But the line#3 gives
compilation
error:
error: no matching function for call to
'std::vector>::push_back(main():: )'
I
don't want a vector of function pointers or vector of function objects. However, vector
of function objects which encapsulate real lambda expressions,
would work for me. Is this possible?
No comments:
Post a Comment