dimanche 3 septembre 2017

Two different implementations of the same template constructor using SFINAE

Is it possible to have two different constructors that get enabled through SFINAE depending on the traits? I have tried the following, but didn't succeed.

class Foo
{
public:
    template<typename F,
    typename FunTrait = typename std::enable_if<std::is_convertible<F, std::function<void(Args...)>>::value>::type>
    Foo(F&& func)
    {
       //Do one thing
    }


    template<typename F,
    typename FunTrait = typename std::enable_if<!std::is_convertible<F, std::function<void(Args...)>>::value>::type>
    Foo(F&& func)
    {
       //Do another thing
    }
}

Aucun commentaire:

Enregistrer un commentaire