vendredi 8 novembre 2019

How to execute a smart pointer object with a member-function-pointer?

I am trying to execute a member-function of a class with a smart pointer instance. The address of this function is passed by value, which I want to call though a smart pointer instance of the respective class.

I already tried this:

(registerList.*setRegister)();

But it errors out:

no match for ‘operator->*

Register class member function:

uint16_t Registers::getSP()
{
    return this->sp;
}

The code snippet:

std::unique_ptr<Registers> registerList;

SetRegisteropcodeLdWordRegister(&Registers::getSP)

void opcodeLdWordRegister(uint16_t (*Registers::setRegister)()) 
{
        (registerList.*setRegister)();
}

Aucun commentaire:

Enregistrer un commentaire