mardi 31 mai 2016

Get the name of a std::function

In the following toy-example, i would like to get the name of a function. The function itself was given as an std::function argument. Is this somehow possible in c++ to get name of a std::function object?

void printName(std::function<void()> func){
    //Need a function name()
    std::cout << func.name();
}

void magic(){};

//somewhere in the code
printName(magic());

output: magic

Otherwise i would have to give the function's name as a second parameter.

Aucun commentaire:

Enregistrer un commentaire