Const function 'return this' best approach?

Hey I have created a UINTERFACE which is solely implemented by actors which has a const function for returning a pointer to itself. Problem is the pointer created to itself using ‘this’ becomes const in a const function. I was wondering what the best approach to removing the const is with UE or if I should make the function non const.

It looks like the following:

UINTERFACE header file:

virtual AActor* GetImplementingActor() const = 0;

Implementing AActor header file:

FORCEINLINE AActor* GetImplementingActor() const override;

Implementing AActor source file:

AActor* AGCoreCharacter::GetImplementingActor() const
{
    return this /* error */
}

The problem is that since your function is const, the expression this is actually a const AActor * but your function “forgets” the const-ness when it returns an AActor*. Either remove the const qualification (if the caller is allowed to mutate the actor through the pointer) or change the declaration to return a const AActor *.