I need two traits concerning integers.
The first one would be like
std::is_integral(orboost::is_integral), but usable with user defined types (for example a class wrapping anint, sayint_wrapper): true if the type behaves like an integer and whose representation is like standard integral types (e.g.sizeof(T) * CHAR_BITS == std::numeric_limits<T>::digitsifTis unsigned) But the definition of an integral type is very rigid, in that it consists of a list of these types. So specializingstd::is_integralseems difficult, if not forbidden (though not stated explicitly I think):is_integralis a "primary" type trait (20.7.4.1, note 3: exactly one primary type trait is true for a type T, in my caseint_wrapperhas alreadyis_classequal to true). What are the risks I take if I specialize this trait forint_wrapper? Do you know of a trait class (e.g. in Boost) that fit my needs?The second trait I need is for types having integer semantics (with bits arithmetic operations, bit manipulations etc.). For example the
mpz_classfrom GMP would satisfy this trait. Isstd::numeric_limits<T>::is_integerappropriate for this trait? I read both that it is OK to specialize and setnumeric_limits<T>::is_integer == trueifTbehaves like an integer, but also (in the C++ standard) that the terms "integral" and "integer" are synonymous (in which case we sould always havenumeric_limits<T>::is_integer == is_integral<T>::value)
In conclusion, am I better of defining my own traits for my precise needs, or try extending standard ones?