When defining a function that takes a function parameter, should I receive a lambda/std::function
by copy, reference or const reference?
Or all three?
When defining a function that takes a function parameter, should I receive a lambda/std::function
by copy, reference or const reference?
Or all three?
I'd go with const ref. Const because the function shouldn't be changed and ref because then the function taking the parameter doesn't have to check for null.
But don't take my word for it, it will depend case by case. Here is a duplicate post that provides other perspectives: