One big advantage of std::function over templates is that if you
write a template, you need to put the whole function in the header
file, whereas std::function does not. This can really help if you’re
working on code that will change a lot and is included by many source
files.
If you want to check if a variable of type std::function is currently
holding a valid function, you can always treat it like a boolean:
mem_fn is faster than bind. so prefer mem_fn first. std::mem_fun can
only deal with member functions that take one or no argument.
std::mem_fn is variadic and can deal with members that take any number
of arguments. You also need to pick between std::mem_fun and
std::mem_fun_ref depending on whether you want to deal with
pointers or references for the class object (respectively). std::mem_fn
alone can deal with either, and even provides support for smart
pointers.