UFUNCTION with template type does not compile

I get the error “Unrecognized type ‘template’ - type must be a UCLASS, USTRUCT or UENUM” when I attempt to use a template type on my UFUNCTION.

This is the function:

	UFUNCTION(BlueprintCallable, Category = "Bugfix")
	template<typename T>
	static inline T SetArrayElement(TArray<T>& Array, uint32 Index, T ArrayElement);

It compiles correctly if I remove the UFUNCTION macro, but I was trying to test if I can circumvent a bug that I get with arrays in blueprint by using C++, so I need to keep that part.

I read something about using the Header Tool to circumvent a similar issue, but I actually do not know how to use it and cannot find any instructions online.

I did some research and found in the past Epic said that UFUNCTION() does not support the template type.

Here is a workaround for using wildcard pins. This sounds like circumventing the header tool that you were referring to:

[Tutorial] How to accept wildcard structs in your UFUNCTIONs - Community Content, Tools and Tutorials - Unreal Engine Forums,

Also, it looks like you are able to use the template type without UFUNCTION in C++ (not blueprints):

the “template” in the first line would be compiled, but you can’t use it in blueprint.
try like the code below:

UFUNCTION(BlueprintCallable, meta = (DeterminesOutputType = "ArrayElement"))
static UObject* SetArrayElement(TArray<UObject*> Array, int32 Index, UObject* ArrayElement);

by the way, Array don’t use &, it means return. uint32 can’t use in blueprint.