Passing C++ Lambda Functions

There’s no need to add the knee-jerk [&]-capture. Your lambda doesn’t need it:

[] (int x) -> bool { return (x == 0); }

Captureless lambdas are convertible to the corresponding function pointer, so this should work out of the box.

That said, you should probably declare the select function to accept std::function, to which all lambdas are convertible, capturing or not:

Container<T> select(std::function<bool(const T&)> predicate) const;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)