I have a typedef:
typedef S32(iMyDataClass1::*getDataFunction_t)(void);
and type:
struct functionMap_t {
std::vector<getDataFunction_t> pDataFunctionTable;
struct dataRequestor_t dataRequestor;
};
Then I have a member variable:
functionMap_t FnMap1;
What then did I configure in the list of member initializers:
myClass::myClass() : FnMap1({
{
&iMyDataClass1::getData1,
&iMyDataClass1::getData2,
&iMyDataClass1::getData3
},
dataRequestor1
})
What I then use in the constructor:
addNewFnMap(FnMap1);
It all works great. Unfortunately, it does not expand for function pointers to different classes, since it is getDataFunction_tbound to pointers iniMyDataClass1
I tried using templates, but ran into problems that I could not get around. Now I am trying to use std::function, which means that I am changing the original typedef to (I think):
typedef std::function<S32(void)> getDataFunction_t;
What is the correct way to configure the initializer list in this situation? Use here std::bind?
:
. , , , :
{
{
(std::bind(&iMyDataClass1::getData1, functionToFetchCorrectObject())),
(std::bind(&iMyDataClass1::getData2, functionToFetchCorrectObject())),
(std::bind(&iMyDataClass1::getData3, functionToFetchCorrectObject()))
},
PGN65370
}