#include <iostream>
using namespace std;
template <typename T>
class has_foo
{
typedef char yes;
typedef long no;
template <typename U, U> class signature_check;
template <typename C> static yes test(signature_check<void (C::*)(int), &C::foo>*);
template <typename C> static no test(...);
public:
static const bool value = (sizeof(test<T>(0)) == sizeof(yes));
};
struct Base
{
void foo(int);
};
struct Derived : public Base
{
};
int main() {
cout << "Base: " << has_foo<Base>::value << endl;
cout << "Derived: " << has_foo<Derived>::value << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIGhhc19mb28KewogIHR5cGVkZWYgY2hhciB5ZXM7CiAgdHlwZWRlZiBsb25nIG5vOwoKICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVSwgVT4gY2xhc3Mgc2lnbmF0dXJlX2NoZWNrOwogIHRlbXBsYXRlIDx0eXBlbmFtZSBDPiBzdGF0aWMgeWVzIHRlc3Qoc2lnbmF0dXJlX2NoZWNrPHZvaWQgKEM6OiopKGludCksICZDOjpmb28+Kik7CiAgdGVtcGxhdGUgPHR5cGVuYW1lIEM+IHN0YXRpYyBubyB0ZXN0KC4uLik7CgpwdWJsaWM6CiAgc3RhdGljIGNvbnN0IGJvb2wgdmFsdWUgPSAoc2l6ZW9mKHRlc3Q8VD4oMCkpID09IHNpemVvZih5ZXMpKTsKfTsKCnN0cnVjdCBCYXNlCnsKCXZvaWQgZm9vKGludCk7Cn07CgpzdHJ1Y3QgRGVyaXZlZCA6IHB1YmxpYyBCYXNlCnsKfTsKCgppbnQgbWFpbigpIHsKCWNvdXQgPDwgIkJhc2U6ICIgPDwgaGFzX2ZvbzxCYXNlPjo6dmFsdWUgPDwgZW5kbDsKCWNvdXQgPDwgIkRlcml2ZWQ6ICIgPDwgaGFzX2ZvbzxEZXJpdmVkPjo6dmFsdWUgPDwgZW5kbDsKfQ==