I have the following function:
template <typename Range>
Range FindFirstIf(Range rng, bool (*Function)(typename Range::ConstReference value))
To this function, I am trying to pass a lambda function like this:
rng = FindFirstIf(rng, [](const float& val) { return (v < 0.0f); });
Where rng
is Range of List of floats, so Range::ConstReference
is defined as const float&
My compiler (gcc) complains about type mismatch
C:\Programming\Collections\main.cpp|24|note: mismatched types 'bool (*)(typename Range::ConstReference)' and 'main(int, char**)::< lambda(const float&) >'|
Can anybody tell me what is wrong with my code?
Edit:
When I pass function like this, it works:
bool (*func)(const float& v) = [](const float& v) { return v < 0.0f; };
When I try to use auto keyword, it is same problem as before:
auto func = [](const float& v) { return v < 0.0f; };