lundi 15 mars 2021

How do you assign a default value to a

I pass a function pointer to a function using functional, and use a constructor initialization to save it in a local variable for later use. How do I assign a default value to the parameter.

Example:

function<void()> BEGINfILE;
void somefunct(function<void()> BEGINFILE): BEGINfILE(BEGINFILE) {}

But I can't seem to do:

void nullfunct() {}
function<void()> BEGINfILE;
void somefunct(function<void()> BEGINFILE = nullfunct): BEGINfILE(BEGINFILE) {}

or:

void nullfunct() {}
function<void()> BEGINfILE;
void somefunct(function<void()> BEGINFILE) {
   BEGINfILE = BEGINFILE;
}

I've also read that functional is deprecated/removed in C++17. I've tried to find what C++17 does without success.

Aucun commentaire:

Enregistrer un commentaire