samedi 23 mai 2020

Why is this template always evaluated to false_type?

I would like to enable_if a member function exists in a class T, so I try to write the code below.

    template< typename T, typename = void >
    struct has_member_func : std::false_type {};

    template< typename T >
    struct has_member_func< T, decltype(&T::some_func) > : std::true_type {};

However, it always evaluate to std::false_type, even if class T does have a function named some_func. Why?

Aucun commentaire:

Enregistrer un commentaire