Use this instead (note the + ):
vi = MyTest(vi, d, +[](double val) { return (val < 0.0f); });
Lambda functions may in some cases fade out in function pointers, but they are not function pointers for themselves.
In other words, the deduction fails because it expects to work with a pointer to a function, but lambda is not a pointer to a function, it can, of course, be converted, but deduction must be done first, but it cannot be that the lambda does not was the expected type, it can decay into it ... And so on.
By adding + before the lambda, you force the conversion before it is passed to the function, so MyTest will get the actual function pointer, as expected, and the deduction continues.
The following is a minimal working example based on your code:
#include<vector> template <class Range, class ValueType> Range MyTest(Range, ValueType, bool(*Function)(ValueType value)) {} int main() { std::vector <int> vi; double d = 0; vi = MyTest(vi, d, +[](double val) { return (val < 0.0f); }); }
source share