#include #include using namespace std; template class lim { public: static bool sign() { T a(0), b(a-1); return b < a; } static T min() { return T(); } static T max() { T a = ~0; return sign() ? a>>1 : a; } }; int main() { cout << boolalpha; cout << "Type\tsign\tmin\tmax\n"; cout << "char\t" << lim::sign() << '\t' << int(lim::min()) << '\t' << int(lim::max()) << '\n'; cout << "uchar\t" << lim::sign() << '\t' << int(lim::min()) << '\t' << int(lim::max()) << '\n'; cout << "short\t" << lim::sign() << '\t' << lim::min() << '\t' << lim::max() << '\n'; cout << "ushort\t" << lim::sign() << '\t' << lim::min() << '\t' << lim::max() << '\n'; cout << "int\t" << lim::sign() << '\t' << lim::min() << '\t' << lim::max() << '\n'; cout << "uint\t" << lim::sign() << '\t' << lim::min() << '\t' << lim::max() << '\n'; }