Higher-order function: Difference between revisions

Content deleted Content added
Woden (talk | contribs)
No edit summary
C++: fixed a lifetime related bug which causes using a dangling reference to a stack variable (can be confirmed with address sanitizer or static analyzers)
Line 66:
auto twice = [](const std::function<int(int)>& f)
{
return [&f](int x) {
return f(f(x));
};
Line 91:
auto twice = [](const auto& f)
{
return [&f](int x) {
return f(f(x));
};