As far as I know, I have at least following three ways to decare a function which accept closures. Which can be by copying, by reference, or by moving:
void FooCopyLambda(std::function<void()> f) {
// ...
f();
// ...
}
void FooRefLambda(const std::function<void()> &f) {
// ...
f();
// ...
}
void FooMoveLambda(std::function<void()> &&f) {
// ...
f();
// ...
}
What's the proper way to pass lambda as an argument? Why?
Aucun commentaire:
Enregistrer un commentaire