lundi 4 juin 2018

Instantiation of static template member function?

I have a problem, given this snippet of code:

class Thread{
    private:
    template<class t_Funtion, class ... t_Args>
    struct ThreadExiter
    {
        using CallbackType = decltype(std::bind(std::declval<t_Funtion>(), std::declval<t_Args>()...));

        static CallbackType m_Callback;

        template<class ... t_ConstructorArgs>
        ThreadExiter(t_Funtion p_Function, t_ConstructorArgs ... p_Args) :
            m_Callback(std::forward<t_Funtion>(p_Function), std::forward<t_ConstructorArgs&&>(p_Args) ...)
        {
            // Nothing to do
        }
        ~ThreadExiter()
        {
            m_Callback();
        }
    };

How can I instantiate the static member static CallbackType m_Callback; ?

I tried:

template<class t_Funtion, class ... t_Args> 
typename Thread::ThreadExiter<t_Funtion, t_Args...>::CallbackType Thread::ThreadExiter<t_Funtion, t_Args...>::m_Callback

But I got:

error: no matching function for call to 'std::_Bind<int (*(Thread*)) Thread*)>::_Bind()'  typename Thread::ThreadExiter<t_Funtion, t_Args...>::CallbackType Thread::ThreadExiter<t_Funtion, t_Args...>::m_Callback;
                                                               ^

Aucun commentaire:

Enregistrer un commentaire