Boost C++ Libraries: Ticket #6495: consider implementing traits for numeric types in terms of numeric_limits https://svn.boost.org/trac10/ticket/6495 <p> The following type traits </p> <p> is_signed, is_unsigned, is_float, is_integral, are currently implemented by checking against a list of numeric primitives. so far so good. </p> <p> But what happens when one specializes numeric_limits for his own new wizbang numeric type like big_integer, arbitrary_length integer, modular_integer, safe_integer, safe_float, etc. etc. I ideally I would expect to see that the above type traits should "just work" but they won't under the current implementation. </p> <p> Note that specializing std::numeric_limits is permited by the current standard for one's own types (though not for types in the std namespace) so this is an actual problem rather than a hypothetical one. </p> <p> The would leave make_signed, make_unsigned a little bit out in the cold as they're implementation can't be done in terms of std::numeric_limits. </p> <p> admittedly, is_integral might not fit here as it has a very specific meaning, but I think my concern applies to the other ones for regardless. </p> <p> Robert Ramey </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6495 Trac 1.4.3 John Maddock Mon, 30 Jan 2012 19:17:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6495#comment:1 https://svn.boost.org/trac10/ticket/6495#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Nope sorry, the whole raison d'etre of type traits is to inspect the properties of a *type*. is_integer etc will only ever be specialized for built-in types, because "big_integer" is *not* an integer, it's class type. This whole topic has been thrashed out several times (not least when type traits were first proposed), and isn't going to change now. </p> <p> Besides you can get the information you require from numeric_limits directly: </p> <p> is_integer == true </p> <blockquote> <p> All integer types. is_bounded == true </p> <blockquote> <p> has min and max values </p> </blockquote> <p> is_signed == true </p> <blockquote> <p> signed integer otherwise unsigned </p> </blockquote> </blockquote> <p> is_integer == is_exact == false </p> <blockquote> <p> floating point type </p> </blockquote> <p> Regards, John. </p> Ticket