lundi 28 novembre 2016

Use a lambda as a parameter for a C++ function

I would like to use a lambda as a parameter for a C++ function, but I don't know which type to specify in the function declaration. What I would like to do is this:

void myFunction(WhatToPutHere lambda){
    //some things
}

I have tried void myFunction(auto lambda) and void myFunction(void lambda) but none of these codes compiled. In case it matters, the lambda doesn't return anything.

How can I use a lambda as a parameter in a C++ function?

Aucun commentaire:

Enregistrer un commentaire