lundi 29 mai 2023

How can I convert a lambda function arguments and store it in std::function

I have a list of functions stored in a vector:

std::vector<std::function<void(uint32_t)>> mFunctions;

I want to add a function as a public API that accepts a different argument but casts it to uint32_t:

enum class MyHandle : uint32_t { Null = 0; };


void addFunction(std::function<void(MyHandle)> &&fn) {
  mFunctions.push_back(fn);
}

How can I achieve this?

Aucun commentaire:

Enregistrer un commentaire