Custom factor that takes a std::function as the error.
This factor is mainly for creating a custom factor in Python.