mercredi 23 décembre 2015

error defining std::function pointer to an instance of a function template, which is a member of a templated class?

I'm getting the following error trying to declare an std::function pointing to a templated class member.

Error C2672 'std::invoke': no matching overloaded function found

template <typename InputArchive, typename OutputArchive, typename ... Components>
class LevelSerializer {
...
    template <typename Component>
    void initRegistry() {
        ...
        std::function<void(entityx::Entity, OutputArchive)> f(std::bind(&LevelSerializer<InputArchive, OutputArchive, Components...>::saveComponent<Component>, this)); // errors
    }

    ...
    // I'm trying to point to an instance of this function
    template <typename T>
    void saveComponent(entityx::Entity& entity, OutputArchive& archive)
};

entityx::Entity is a fixed (non-template) type. Why does doing this fail?

Aucun commentaire:

Enregistrer un commentaire