Use a templated functor instead of a function pointer.