Thank you for reply. But I did not have a luck.
#include "SomeEmptyPlugin.h"
#include<functional>
#define LOCTEXT_NAMESPACE "FSomeEmptyPluginModule"
void FSomeEmptyPluginModule::SomeTest()
{
DelegateWithoutPayload.BindRaw(
this
, &FSomeEmptyPluginModule::FunctionWithoutParameter
);
DelegateWithValuePayload.BindRaw(
this
, &FSomeEmptyPluginModule::FunctionWithValueParameter
, SomeStruct
);
DelegateWithPointerPayload.BindRaw(
this
, &FSomeEmptyPluginModule::FunctionWithPointerParameter
, &SomeStruct
);
DelegateWithReferencePayload.BindRaw(
this
, &FSomeEmptyPluginModule::FunctionWithReferenceParameter
, std::ref(SomeStruct)
);
void (FSomeEmptyPluginModule::*SomeFunctionPtrWithValueParam)(FSomeStruct) = nullptr;
SomeFunctionPtrWithValueParam = &FSomeEmptyPluginModule::FunctionWithValueParameter;
(this->*SomeFunctionPtrWithValueParam)(this->SomeStruct);
void (FSomeEmptyPluginModule::*SomeFunctionPtrWithRefParam)(FSomeStruct&) = nullptr;
SomeFunctionPtrWithRefParam = &FSomeEmptyPluginModule::FunctionWithReferenceParameter;
(this->*SomeFunctionPtrWithRefParam)(this->SomeStruct);
}
And I got this message. In IDE Toolip,
No viable function. Argument types: FSomeEmptyPluginModule*, void(FSomeEmptyPluginModule::*)(FSomeStruct&), std::reference_wrapper<FSomeStruct>. Candidates considered: inline void BindRaw<UserClass, VarTypes...>(UserClass* InUserObject, typename TMemFunPtrType<false, UserClass, TDelegate<void()>::RetValType(std::decay_t<VarTypes>...)>::Type InFunc, VarTypes&&...) (in class TDelegate<void(), FDefaultDelegateUserPolicy>) conversion of 2nd argument &FSomeEmptyPluginModule::FunctionWithReferenceParameter is ill-formed: cannot convert void(FSomeEmptyPluginModule::*)(FSomeStruct&) to parameter type TMemFunPtrType<false, FSomeEmptyPluginModule, TDelegate<void()>::RetValType(std::decay_t<std::reference_wrapper<FSomeStruct>>)>::Type (aka void(FSomeEmptyPluginModule::*)(std::reference_wrapper<FSomeStruct>)), because source function and target function have different 1st parameter types: FSomeStruct& and std::reference_wrapper<FSomeStruct> inline void BindRaw<UserClass, VarTypes...>(const UserClass* InUserObject, typename TMemFunPtrType<true, UserClass, TDelegate<void()>::RetValType(std::decay_t<VarTypes>...)>::Type InFunc, VarTypes&&...) (in class TDelegate<void(), FDefaultDelegateUserPolicy>) conversion of 2nd argument &FSomeEmptyPluginModule::FunctionWithReferenceParameter is ill-formed: cannot convert void(FSomeEmptyPluginModule::*)(FSomeStruct&) to parameter type TMemFunPtrType<true, FSomeEmptyPluginModule, TDelegate<void()>::RetValType(std::decay_t<std::reference_wrapper<FSomeStruct>>)>::Type (aka void(FSomeEmptyPluginModule::*)(std::reference_wrapper<FSomeStruct>) const), because target function has const qualifier
And in the compile error,
0>Executing up to 12 actions based on MaxProcessorCount override
0>------ Building 4 action(s) started ------
0>[1/4] Compile [x64] Module.SomeEmptyPlugin.cpp
0>SomeEmptyPlugin.cpp(27): Error C2665 : 'TDelegate<void (void),FDefaultDelegateUserPolicy>::BindRaw': no overloaded function could convert all the argument types
0>DelegateSignatureImpl.inl(400): Reference : could be 'void TDelegate<void (void),FDefaultDelegateUserPolicy>::BindRaw<FSomeEmptyPluginModule,std::reference_wrapper<FSomeStruct>>(const UserClass *,void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>) const,std::reference_wrapper<FSomeStruct> &&)'
0> with
0> [
0> UserClass=FSomeEmptyPluginModule
0> ]
0>SomeEmptyPlugin.cpp(27): Reference : 'void TDelegate<void (void),FDefaultDelegateUserPolicy>::BindRaw<FSomeEmptyPluginModule,std::reference_wrapper<FSomeStruct>>(const UserClass *,void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>) const,std::reference_wrapper<FSomeStruct> &&)': cannot convert argument 2 from 'void (__cdecl FSomeEmptyPluginModule::* )(FSomeStruct &)' to 'void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>) const'
0> with
0> [
0> UserClass=FSomeEmptyPluginModule
0> ]
0>SomeEmptyPlugin.cpp(29): Reference : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
0>DelegateSignatureImpl.inl(393): Reference : or 'void TDelegate<void (void),FDefaultDelegateUserPolicy>::BindRaw<FSomeEmptyPluginModule,std::reference_wrapper<FSomeStruct>>(UserClass *,void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>),std::reference_wrapper<FSomeStruct> &&)'
0> with
0> [
0> UserClass=FSomeEmptyPluginModule
0> ]
0>SomeEmptyPlugin.cpp(27): Reference : 'void TDelegate<void (void),FDefaultDelegateUserPolicy>::BindRaw<FSomeEmptyPluginModule,std::reference_wrapper<FSomeStruct>>(UserClass *,void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>),std::reference_wrapper<FSomeStruct> &&)': cannot convert argument 2 from 'void (__cdecl FSomeEmptyPluginModule::* )(FSomeStruct &)' to 'void (__cdecl FSomeEmptyPluginModule::* )(std::reference_wrapper<FSomeStruct>)'
0> with
0> [
0> UserClass=FSomeEmptyPluginModule
0> ]
0>SomeEmptyPlugin.cpp(29): Reference : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
0>SomeEmptyPlugin.cpp(27): Reference : while trying to match the argument list '(FSomeEmptyPluginModule *, void (__cdecl FSomeEmptyPluginModule::* )(FSomeStruct &), std::reference_wrapper<FSomeStruct>)'