What types in delegates declarations are supprted?

There are next macros for delegates declarations:

  1. DECLARE_DELEGATE (for code usage)
  2. DECLARE_DYNAMIC_MULTICAST_DELEGATE (for blueprint usage additionally)

If I want to use blueprintable delegates I can just use second type and I must specify types only supported by blueprint: such as int32, TArray, UObjects, etc.

But if I want to use TMap in first type delegates?
DECLARE_DELEGATE_TwoParams(FDelegateName, int32, TMap);

But this declaration failed because in round brackets of macro substitutor used three comma instead two (in TMap template there additional comma).
So I can’t use TMap in delegates?
Or I can use special macros to avoid this?

For example

#define COMBINED(a, ...) a, ##__VA_ARGS__
DECLARE_DELEGATE_TwoParams(FDelegateName, int32, COMBINED(TMap<int32, UObject>));

Or there another way to declare delegates?

And can I use TMap in DECLARE_DYNAMIC_MULTICAST_DELEGATE without exposing to blueprint?

Thanks!

I’m not quite sure what you’re asking to be honest. So I’ll attempt to answer it this way… I don’t think you can use a TMap with a dynamic multicast delegate since IIRC all parameters must be UObject/UStruct or the like. Also I’m not sure the best way to get around compiler errors with delegates and templated classes like TMap, but the easiest I’ve seen was to typdef it and use the typdef instead of the full template. So for example…

typedef TMap<int32, UObject> MyMap;
DECLARE_DELEGATE_TwoParams(FDelegateName, int32, MyMap);

Hopefully that helps!

Thank you for answer, Koderz.
Okay, typedef sounds better then using macro, but if I used this for code generation, with variadic parameters and variadic types of parameters, typdef is excess.

typedef TMap<int32, UObject> MyMap;

Do not work

Unrecognized type 'MyMap' - type must be a UCLASS, USTRUCT or UENUM
1 Like

I’m not found variants for dynamic multicast for now… Need an another question for this type delegates.