Assign Std bind to std function fails

Trying to initialise std::function with std::bind fails

void mfo_InitObject(const C_Config_cpp* pConfig);

std::function<void(const C_Config_cpp*)> mvo_objectInitFunc = std::bind(&MyGameMode::mfo_InitObject, this);

getting error below

error C2679 : binary '=' : no operator found which takes a right - hand operand of type 'std::_Binder<std::_Unforced,void (__cdecl MyGameMode::* )(const C_Config_cpp *),MyGameMode *>' (or there is no acceptable conversion)

This project is based on Ue4 c++ and pure c++ sections, trying to avoid using ue4 api for this, so no delegates, just pure c++.

I tried the same thing in non ue4 vs2019 console project and it works fine.

Any help much welcome

cheers

If mfo_InitObject is non-static member function then bind should be

std::function<void(const C_Config_cpp*)> func = std::bind(&MyGameMode::mfo_InitObject, this, std::placeholders::_1);
1 Like

thank you very much that did it, cheers