mardi 26 septembre 2023

Eliminating use of binary_function and result_type

I am trying to update an abandoned open source library to C++11 and 17. It uses binary_function and its result_type in a way I am not sure how to remove. These features were deprecated in C++11 and removed in 17.

First, I've simply removed binary_function (and urnary_function) from this file https://github.com/ramcdona/Pinocchio/blob/master/Pinocchio/mathutils.h#L44

Next, I'm unsure how to eliminate the use of result_type in places like this. https://github.com/ramcdona/Pinocchio/blob/master/Pinocchio/vector.h#L247

  template<class R, int D, class F>
    static Vector<typename F::result_type, D> apply(const F &func, const VRD &v)
    {
        Vector<typename F::result_type, D> out;
        _apply(func, v, out);
        return out;
    }

I tried replacing Vector<typename F::result_type, D> with 'auto', but my compiler (currently set to C++11) complained that auto for return types is introduced in C++14.

F is a generic functor. How can I re-write the above code when I don't know what result_type is?

Aucun commentaire:

Enregistrer un commentaire