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 as follows:
rng = FindFirstIf(rng, [](const float& val) { return (v < 0.0f); });
Where rng is the range of the float list, 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 someone tell me what is wrong with my code?
Edit:
When I pass a function like this, it works:
bool (*func)(const float& v) = [](const float& v) { return v < 0.0f; };
When I try to use the auto keyword, this is the same problem as before:
auto func = [](const float& v) { return v < 0.0f; };
source share