[v3] C++0x type_traits post-oxford additions

Howard Hinnant hhinnant@apple.com
Mon May 7 16:53:00 GMT 2007


On May 7, 2007, at 10:13 AM, Benjamin Kosnik wrote:

>
>> make_signed/make_unsigned require:
>>> Requires: T is a cv integral type or enumeration, but not a bool  
>>> type.
>> I.e. they are not supposed to work with floating point types.
>
> Huh. Now that I look at this, I'm wondering why is_signed/ 
> is_unsigned work on all arithematic types where T(-1) < T(0), and  
> make_signed/make_unsigned only work on all integral types except  
> bool plus enumerated types? What's the reason for the inconsistency?
>
> I don't see this in the rationale.

For is_(un)signed the motivation for including floating point types is:

*  Consistency with numeric_limits<T>::is_signed

*  Because asking if an arithmetic types supports negative values is  
a reasonable question with a well defined answer for all arithmetic  
types.

For make_(un)signed floating point types were not included because:

*  I wasn't aware of any use cases.

*  The semantics of make_signed<double>::type and  
make_unsigned<double>::type didn't seem obviously clear.

*  As I recall when I surveyed my own implementation, and other  
implementations I found, no one had applied this functionality to  
floating point types (so no existing practice).

*  make_(un)signed<long double> seems fragile / non-portable.

That being said, please feel free to send me a defect report if you  
would like to see make_(un)signed applied to floating point types.

-Howard




More information about the Libstdc++ mailing list