SFINAE para verificar las funciones miembro heredadas

Utilizando SFINAE, ipuede detectar Si una clase dada tiene una determinada función miembro. Pero, ¿y si quiero probar las funciones de miembro heredadas?

Lo siguiente no funciona en VC8 y GCC4 (es decir, detecta queA tiene una función de miembrofoo()pero no esoB hereda uno):

#include <iostream>

template<typename T, typename Sig>                                 
struct has_foo {                     
    template <typename U, U> struct type_check;
    template <typename V> static char (& chk(type_check<Sig, &V::foo>*))[1];
    template <typename  > static char (& chk(...))[2]; 
    static bool const value = (sizeof(chk<T>(0)) == 1);
};

struct A {
    void foo();
};

struct B : A {};

int main()
{
    using namespace std;
    cout << boolalpha << has_foo<A, void (A::*)()>::value << endl; // true
    cout << boolalpha << has_foo<B, void (B::*)()>::value << endl; // false
}

Entonces, ¿hay una manera de probar las funciones miembro heredadas?

Respuestas a la pregunta(4)

Su respuesta a la pregunta