Use unique_function where appropriate to support movable-only arguments