samedi 25 janvier 2020

Template member std::function of none templated class

I have a class that it has a templated function

class DialogManager
{
public:
    template<class T>
    using TimeoutCallback = std::function<void (T)>;

    DialogManager();
    virtual ~DialogManager();

    template<class T>
    void SetTimeoutCallback(TimeoutCallback<T> callback);

private:
    TimeoutCallback mTimeoutCallback;
}

I get below error:

error: invalid use of template-name ‘DialogManager::TimeoutCallback’ without an argument list

I've changed code to

template<class T>
TimeoutCallback<T> mTimeoutCallback;

but I a got another compiler's error

error: data member ‘mTimeoutCallback’ cannot be a member template

Aucun commentaire:

Enregistrer un commentaire