struct P{};
struct Q{bool operator()(int);};
struct R{int operator()();};
struct S{bool operator()();};
struct T{bool operator()() const;};
struct U{bool operator()() volatile;};
struct V{bool operator()() const volatile;};
template <unsigned N>
class TIntToType
{
TIntToType();
};
template <class>
struct TIsNullaryFunction
{
static const bool Value_ = false;
};
template <class TResult>
struct TIsNullaryFunction<TResult (*)()>
{
static const bool Value_ = true;
};
template <class TFunctor>
class TIsNullaryFunctor
{
template <class T, T>
class TTester;
template <class T>
static char Test(TTester<bool (T::*)(), &T::operator()>*);
template <class T>
static char Test(TTester<bool (T::*)() const, &T::operator()>*);
template <class T>
static char Test(TTester<bool (T::*)() volatile, &T::operator()>*);
template <class T>
static char Test(TTester<bool (T::*)() const volatile, &T::operator()>*);
typedef char TTwoChars[2];
template <class>
static TTwoChars& Test(...);
public:
static const bool Value_ = sizeof(Test<TFunctor>(0)) == 1;
};
template <class TFunctor>
struct TIsNullaryCallable
{
static const bool Value_ = TIsNullaryFunction<TFunctor>::Value_
|| TIsNullaryFunctor<TFunctor>::Value_;
};
#include <iostream>
int main()
{
std::cout <<
TIsNullaryCallable<int>::Value_ <<
TIsNullaryCallable<P>::Value_ <<
TIsNullaryCallable<Q>::Value_ <<
TIsNullaryCallable<R>::Value_ <<
TIsNullaryCallable<int (*)()>::Value_ <<
TIsNullaryCallable<S>::Value_ <<
TIsNullaryCallable<T>::Value_ <<
TIsNullaryCallable<U>::Value_ <<
TIsNullaryCallable<V>::Value_ << std::endl;
}