#include <cstddef>
#include <string>
#include <type_traits>
template <class C>
class HasGreetMethod
{
template <class T>
static std::true_type testSignature(void (T::*)(const char*) const);
template <class T>
static decltype(testSignature(&T::greet)) test(std::nullptr_t);
template <class T>
static std::false_type test(...);
public:
using type = decltype(test<C>(nullptr));
static const bool value = type::value;
};
struct A
{
void greet(const char* name) const;
};
struct Derived : A { };
struct B
{
void greet(std::string name) const;
};
static_assert(HasGreetMethod<A>::value, "");
static_assert(HasGreetMethod<Derived>::value, "");
static_assert(!HasGreetMethod<B>::value, "");
int main()
{
return 0;
}
I2luY2x1ZGUgPGNzdGRkZWY+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDx0eXBlX3RyYWl0cz4KCnRlbXBsYXRlIDxjbGFzcyBDPgpjbGFzcyBIYXNHcmVldE1ldGhvZAp7CiAgICB0ZW1wbGF0ZSA8Y2xhc3MgVD4KICAgIHN0YXRpYyBzdGQ6OnRydWVfdHlwZSB0ZXN0U2lnbmF0dXJlKHZvaWQgKFQ6OiopKGNvbnN0IGNoYXIqKSBjb25zdCk7CgogICAgdGVtcGxhdGUgPGNsYXNzIFQ+CiAgICBzdGF0aWMgZGVjbHR5cGUodGVzdFNpZ25hdHVyZSgmVDo6Z3JlZXQpKSB0ZXN0KHN0ZDo6bnVsbHB0cl90KTsKCiAgICB0ZW1wbGF0ZSA8Y2xhc3MgVD4KICAgIHN0YXRpYyBzdGQ6OmZhbHNlX3R5cGUgdGVzdCguLi4pOwoKcHVibGljOgogICAgdXNpbmcgdHlwZSA9IGRlY2x0eXBlKHRlc3Q8Qz4obnVsbHB0cikpOwogICAgc3RhdGljIGNvbnN0IGJvb2wgdmFsdWUgPSB0eXBlOjp2YWx1ZTsKfTsKCnN0cnVjdCBBCnsKICAgIHZvaWQgZ3JlZXQoY29uc3QgY2hhciogbmFtZSkgY29uc3Q7Cn07CgpzdHJ1Y3QgRGVyaXZlZCA6IEEgeyB9OwoKc3RydWN0IEIKewogICAgdm9pZCBncmVldCh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