Declare a const delegate

Hello,

It says here that you can declare a const delegate with “_CONST”, however it doesn’t seem to work for me.

DECLARE_DYNAMIC_DELEGATE(FDelegateName);

works just fine, however

DECLARE_DYNAMIC_DELEGATE_Const(FDelegateName);

spits out compile errors.

Error	1	error C2065: 'FDelegateName' : undeclared identifier
Error	2	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Does anybody have any idea how to get this working?

This actually looks like a bug, cause I don’t see the _Const macro define in the macro file.

Yeah, I didn’t either. Was it deprecated perhaps? Trouble is I can find absolutely no examples or references for const function delegates other than that documentation.

Hey Acren-

Are you using the _Const inside of square brackets? Try using DECLARE_DYNAMIC_DELEGATE[_Const](FDelegateName) and let me know if you still get compile errors.

Cheers

Doug Wilson

That fails with

Missing '(' in Delegate Declaration

Hey Acren-

I’ve entered a bug report (UE-20503) to investigate constant dynamic delegate creation in C++.

Cheers

Doug Wilson

Any word on this?

The bug report mentioned is still open and unresolved. It may be helpful to look at the DelegateSignatureImpl.inl file of the engine for examples on adding UObject-based function delegates.

There used to be a _Const version of the delegate signature, but it hasn’t existed for some time (since late 2012 actually). We apparently didn’t update the documentation to reflect this. We just fixed it locally and it will be live shortly.

Sorry for any confusion that caused. Outdated documentation is a horrible thing, but it does happen with a codebase this large that changes so frequently.

To clarifty: const functions are supported, you don’t need the _Const version of delegates anymore.