#include <iostream>
struct P{};
struct S{bool operator()(){return true;}};
template <class TFunctor>
class TIsCallable
{
typedef char TTwoChars[2];
template <class T>
static char Test(int[sizeof((*((T*)0))())]);
template <class>
static TTwoChars& Test(...);
public:
static const bool Value_ = sizeof(Test<TFunctor>(0)) == 1;
};
int main()
{
std::cout
<< TIsCallable<int>::Value_
<< TIsCallable<P>::Value_
<< TIsCallable<int (*)()>::Value_
<< TIsCallable<S>::Value_ << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IFB7fTsKCnN0cnVjdCBTe2Jvb2wgb3BlcmF0b3IoKSgpe3JldHVybiB0cnVlO319OwoKdGVtcGxhdGUgPGNsYXNzIFRGdW5jdG9yPgpjbGFzcyBUSXNDYWxsYWJsZQp7ICAgCiAgICB0eXBlZGVmIGNoYXIgVFR3b0NoYXJzWzJdOwogICAgdGVtcGxhdGUgPGNsYXNzIFQ+CiAgICBzdGF0aWMgY2hhciBUZXN0KGludFtzaXplb2YoKCooKFQqKTApKSgpKV0pOwoKICAgIHRlbXBsYXRlIDxjbGFzcz4KICAgIHN0YXRpYyBUVHdvQ2hhcnMmIFRlc3QoLi4uKTsKcHVibGljOgogICAgc3RhdGljIGNvbnN0IGJvb2wgVmFsdWVfID0gc2l6ZW9mKFRlc3Q8VEZ1bmN0b3I+KDApKSA9PSAxOwp9OwoKaW50IG1haW4oKQp7ICAgCiAgICBzdGQ6OmNvdXQKICAgICAgICA8PCBUSXNDYWxsYWJsZTxpbnQ+OjpWYWx1ZV8KICAgICAgICA8PCBUSXNDYWxsYWJsZTxQPjo6VmFsdWVfCiAgICAgICAgPDwgVElzQ2FsbGFibGU8aW50ICgqKSgpPjo6VmFsdWVfCiAgICAgICAgPDwgVElzQ2FsbGFibGU8Uz46OlZhbHVlXyA8PCBzdGQ6OmVuZGw7Cn0K