x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.14
Tags:
more ▼

asked Dec 28 '16 at 01:13 PM in C++ Programming

avatar image

vb4
18 2 4 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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

https://answers.unrealengine.com/questions/7102/request-blueprints-support-for-template-types.html

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

https://forums.unrealengine.com/showthread.php?56537-Tutorial-How-to-accept-wildcard-structs-in-your-UFUNCTIONs&p=206131#post206131%29,

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

https://wiki.unrealengine.com/Templates_in_C%2B%2B

more ▼

answered Dec 28 '16 at 06:17 PM

avatar image

Dartanlla
2.6k 61 26 281

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question