بالنسبة للـIF فقد تعمدت وضعها حتى يظهر Compile error عندما لا يتحقق الشرط
على كل حال هذا هو الكود المطلوب ولكنه لا يحقق المجال المطلوب .. (وحصلت على all test passed)
#include <iostream>
#include <climits>
using std::cout;
using std::endl;
typedef unsigned long long int ulli;
template <typename x>struct getMax{static const ulli max = 0;};
template <>struct getMax<unsigned char >{static const ulli max = UCHAR_MAX ;};
template <>struct getMax<signed char >{static const ulli max = CHAR_MAX ;};
template <>struct getMax<unsigned short int >{static const ulli max = USHRT_MAX ;};
template <>struct getMax<signed short int >{static const ulli max = SHRT_MAX ;};
template <>struct getMax<unsigned int >{static const ulli max = UINT_MAX ;};
template <>struct getMax<signed int >{static const ulli max = INT_MAX ;};
template <>struct getMax<unsigned long long int >{static const ulli max = ULLONG_MAX;};
template <>struct getMax<signed long long int >{static const ulli max = LLONG_MAX;};
template<ulli base ,ulli num >
struct counter
{
static const ulli value = (counter<base,num/base>::value)+bool(num);
};
template<ulli base>
struct counter<base,0>
{
static const ulli value = 0;
};
template < typename tName , ulli base = 10 >
struct digits_in_base_for_type
{
static const ulli value =
(base<2||((base-1)<=getMax<tName>::max))?counter < base , getMax<tName>::max >::value : 0;
};فكيف أمنع المستخدم من إضافة القيم الممنوعة ؟