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"

Delegate with TMap working when it shouldn't.

I was having problems with declaring a delegate with a TMap as a parameter, kept getting that I had too many parameters in this declaration:

 DECLARE_DELEGATE_FiveParams(FOnAlarmJsonParsed, TArray<FIvivaAlarm>, TMap<UObject*, TArray<FIvivaAlarm>>, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>);

I was about to wrap the map in a struct, when I thought I'd see if just declaring it as a six parameter delegate would work at all. It did, not only that, but there don't seem to be any noticeable issues. Here's the declaration:

 DECLARE_DELEGATE_SixParams(FOnAlarmJsonParsed, TArray<FIvivaAlarm>, TMap<UObject*, TArray<FIvivaAlarm>>, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>);

This seems incorrect... anyone know why it works?

Product Version: UE 4.15
Tags:
more ▼

asked May 15 '17 at 04:33 AM in C++ Programming

avatar image

mjk0104
6 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi,

It works because of how the token expansion occurs inside the macro, but I would say it's not something you should learn to rely on. A better solution would be to typedef your type:

 typedef TMap<UObject*, TArray<FIvivaAlarm>> FMyMap;

 DECLARE_DELEGATE_FiveParams(FOnAlarmJsonParsed, TArray<FIvivaAlarm>, FMyMap, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>, TArray<FIvivaAlarm>);

Hope this helps,

Steve

more ▼

answered May 15 '17 at 03:08 PM

avatar image

Steve Robb STAFF
2.6k 58 24 96

avatar image Socke81 May 07 '18 at 03:40 PM

error : Unrecognized type 'FMyMap' - type must be a UCLASS, USTRUCT or UENUM

avatar image Steve Robb STAFF May 08 '18 at 11:48 AM

This trick doesn't work for dynamic delegates, unfortunately, as UnrealHeaderTool doesn't understand typedefs. In that case, you should put your map inside a USTRUCT and then pass that instead.

Steve

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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