No matching function call to jlimit

I’m calling jlimit in void drawNextLineOfSpectrogram() as I found it in the tutorial,
but I am getting the error “No matching function call to jlimit”.

I see it defined in juce_core/maths/juce_MathFunctions.h

I’m also calling jmin and jmax and they are working fine. He is my code:

    for (auto y = 1; y < imageHeight; ++y)
        auto skewedProportionY = 1.0f - std::exp (std::log (y / (float) imageHeight) * 0.2f);
        auto fftDataIndex = jlimit (0, fftSize, (int) (skewedProportionY * fftSize));
        auto level = jmap (phase[fftDataIndex], 0.0f, jmax (maxLevel.getEnd(), 1e-5f), 0.0f, 1.0f);

        spectrogramImage.setPixelAt (rightHandEdge, y, Colour::fromHSV (level, 1.0f, level, 1.0f));

Please if someone call tell me why the compiler is not seeing the jlimit definition that would be great. Thanks.

jlimit is a function template that is pretty particular about the type of the arguments if you don’t provide the type explicitly. (Is fftSize maybe an unsigned int?) You could try jlimit<int> instead of jlimit

Explicitly specifying the template type is usually the wrong approach, it’s better to adjust the function argument types (perhaps by adding some explicit casts) so that the compiler can work out which template function you’re trying to call. For jlimit all arguments should have the same type.