Delegates container

Hi,

You shouldn’t be including those headers - they are correctly imported for you in Core.h, which is included by everything anyway.

There is no common base type for delegates - delegates are value types, not reference types - and so you shouldn’t think of them in terms of pointers to base classes. Just like int and float don’t have a common ‘number’ base class.

Maybe if you clarified what you are trying to do here, we could come up with a solution. You wouldn’t be able to do anything with those delegates if there was a common base class, because there’d be no common signature to execute them. That’s why you usually declare your delegate type in advance.

As says, only dynamic delegates are usable by the reflection system, so if you wanted to have a UFunction, you’d have to do something like:

DECLARE_DYNAMIC_DELEGATE(FMyEvent)

UCLASS()
class UThing : public UObject
{
    GENERATED_BODY()

public:
    UFUNCTION()
    virtual TArray<FMyEvent> GetEvents();
};

If you remove the UFUNCTION, you can make it a non-dynamic delegate, but the same issues with a lack of common base class remain.

Steve

1 Like