I have a class called SoundThreadManager.
It defines a function:
1 2
|
void Init(f_GetSoundSample getSoundSample, f_SoundConverted playSound, int sampleRate, int sampleSize);
|
and a function pointer:
1 2
|
typedef byte*(__stdcall* f_GetSoundSample) (byte*, int);
|
I also have a class called 'OSystem_Cli', which has a function
1 2
|
byte* mixCallback(byte* samples, int sampleSize);
|
I need to pass this member function to the Init function of SoundThreadManager.
I attempted to use a std::bind to create such a function pointer like this:
|
auto fn1 = &std::bind(&OSystem_Cli::mixCallback, *_gSystemCli, std::placeholders::_1, std::placeholders::_2);
|
However I get this error in a file called xmemory:
Error C2661 'std::tuple<OSystem_Cli,std::_Ph<1>,std::_Ph<2>>::tuple': no overloaded function takes 3 arguments CLIScumm C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.25.28610\include\xmemory 1358
I also tried:
|
auto fn1 = &std::bind(&OSystem_Cli::mixCallback, _gSystemCli, std::placeholders::_1, std::placeholders::_2);
|
But I get this error:
Error C2664 'std::_Binder<std::_Unforced,byte *(__thiscall OSystem_Cli::* )(byte *,int),OSystem_Cli *&,const std::_Ph<1> &,const std::_Ph<2> &> std::bind<byte*(__thiscall OSystem_Cli::* )(byte *,int),OSystem_Cli*&,const std::_Ph<1>&,const std::_Ph<2>&>(_Fx &&,OSystem_Cli *&,const std::_Ph<1> &,const std::_Ph<2> &)': cannot convert argument 2 from 'OSystem_Cli *' to 'OSystem_Cli *&' CLIScumm C:\ScummVMNew\ScummVMWeb\GIT\dists\CLIScumm\Wrapper.cpp 112
Note: _gSystemCli is a pointer to a type of OSystem_Cli.
I followed this example:
https://stackoverflow.com/questions/37636373/how-stdbind-works-with-member-functions