Calling FindComponentByClass inside another Template method

Hi Guys,

I am new to Unreal Engine programming, especially in C++. What I am trying to do is write a generic template method that can tell you whether a particular type of component is attached to an actor or not.

My function is like this

void UGrabber::AreComponentsAttached(const TSubclassOf<UActorComponent> ComponentClass) const
    UActorComponent *Component = this->GetOwner()->FindComponentByClass<UActorComponent>();
    if (!Component)
         UE_LOG(LogTemp, Warning, TEXT("Nothing is There"));

And Ideally what I want is something like this

AreComponentsAttached<UPhysicsHandlerComponent>() and AreComponentsAttached<USomeRandomComponent>();

Any help will be great