Function reference type needs 'void', but gets 'return'

Hi! I have this function for my timer:


timeManager->SetTimer(AnimationTimeHandler, this, &UAnimatedImageTexture::Animate, fAnimationSpeed, true);

when UAnimatedImageTexture::Animate return type is void, all works fine. But, say, it is bool - and I get an error. What is the syntax to cast that function reference to ‘void’ in such scenario?

I believe u can’t cast a function to void, but u can write a wrapper function to use with the timer.



bool MyFunction()
{
    return true;
}

void MyFunctionTimerWrapper()
{
    MyFunction();
}


You can’t do that. You cannot convert between different function pointer types. If function wants void function pointer, then it will only accept void function pointers and nothing else. If you force conversion, it will simply crash the program.

Use lambda function and pass your boolean value through some reference or pointer to another variable.