dimanche 16 juillet 2017

Moving implementation from .h to .hpp with enable if statements

If I have a function that has an enable if statement in the typename declarations, how do I move that function to a separate implementation file, like an included .hpp file in my case?

template<typename... Args>
class delegate
{

    template<typename F, 
        typename = typename std::enable_if<
        std::is_convertible<F, std::function<void(Args...)>>::value>::type>
    delegate(F&& func)          
        : function(std::forward<F>(func))
    {
    }

}

Where do I need to keep the std::enable_if and where can I get rid of it. Do I only need it in the header file?

template<typename... Args>
template<typename F,
    typename = typename std::enable_if<
    std::is_convertible<F, std::function<void(Args...)>>::value>::type>
delegate<Args...>::delegate(F&& func)
    : function(std::forward<F>(func))
{
}

Aucun commentaire:

Enregistrer un commentaire