I'm trying to create a list of function pointers, and these functions is passed as lambda.
string msg = "hello";
vector<string (*)() > myvector;
auto f = [=]() -> string {return msg; };
myvector.push_back(f);
cout << (*myvector[0])();
However, I got error in compiling when tried to capture variable and it successed when i didn't capture anything. This problem occur when i use map, pair or sth similar.
funtionPointer.cc:36:22: error: no matching function for call to ‘std::vector<std::__cxx11::basic_string<char> (*)()>::push_back(main()::<lambda()>&)’
myvector.push_back(f);
Thank for any help.