#optimization

Following code can be used to detect if a blueprint implementation for some function exists. This can be a useful optimization in some circumstances.

auto ImplementedInBlueprint = [](const UFunction* Func) -> bool
{
	return Func && ensure(Func->GetOuter())
		&& Func->GetOuter()->IsA(UBlueprintGeneratedClass::StaticClass());
};
 
static FName FuncName = FName(TEXT("MyFunctionName"));
UFunction* ShouldRespondFunction = GetClass()->FindFunctionByName(FuncName);
bHasBlueprintMyFunction = ImplementedInBlueprint(ShouldRespondFunction);
 
 
//Then use this to check which function to call:
if(bHasBlueprintMyFunction)
{
	MyFunctionName();
}
else
{
	//If this is a BlueprintNativeEvent, we can call the C++
	//implementation directly if a BP version doesn't exist
	MyFunctionName_Implementation();
}