title: integer traits (is_integer, is_integral)
body: <p>I need two traits concerning integers.</p>
  
  <ol>
  <li><p>The first one would be like <code>std::is_integral</code> (or <code>boost::is_integral</code>), but usable with user defined types (for example a class wrapping an <code>int</code>, say <code>int_wrapper</code>): true if the type behaves like an integer and whose representation is like standard integral types (e.g. <code>sizeof(T) * CHAR_BITS == std::numeric_limits&lt;T&gt;::digits</code> if <code>T</code> is unsigned) But the definition of an integral type is very rigid, in that it consists of a list of these types. So specializing <code>std::is_integral</code> seems difficult, if not forbidden (though not stated explicitly I think): <code>is_integral</code> is a "primary" type trait (20.7.4.1, note 3: exactly one primary type trait is true for a type T, in my case <code>int_wrapper</code> has already <code>is_class</code> equal to true).
  What are the risks I take if I specialize this trait for <code>int_wrapper</code>?
  Do you know of a trait class (e.g. in Boost) that fit my needs?</p></li>
  <li><p>The second trait I need is for types having integer semantics (with bits arithmetic operations, bit manipulations etc.). For example the <code>mpz_class</code> from GMP would satisfy this trait. Is <code>std::numeric_limits&lt;T&gt;::is_integer</code> appropriate for this trait? I read both that it is OK to specialize and set <code>numeric_limits&lt;T&gt;::is_integer == true</code> if <code>T</code> behaves like an integer, but also (in the C++ standard) that the terms "integral" and "integer" are synonymous (in which case we sould always have <code>numeric_limits&lt;T&gt;::is_integer == is_integral&lt;T&gt;::value</code>)</p></li>
  </ol>
  
  <p>In conclusion, am I better of defining my own traits for my precise needs, or try extending standard ones? </p>