[v3] ext/type_traits.h
Howard Hinnant
hhinnant@apple.com
Sun Sep 24 19:55:00 GMT 2006
On Sep 15, 2006, at 10:19 AM, Peter Doerfler wrote:
>> Index: include/tr1/random.tcc
>> ===================================================================
>> --- include/tr1/random.tcc (revision 116965)
>> +++ include/tr1/random.tcc (working copy)
>> @@ -88,34 +88,26 @@
>> };
>>
>> template<typename _ValueT>
>> - struct _To_Unsigned_Type
>> + struct _To_unsigned_type
>> { typedef _ValueT _Type; };
>>
>> template<>
>> - struct _To_Unsigned_Type<short>
>> + struct _To_unsigned_type<short>
>> { typedef unsigned short _Type; };
>>
>> template<>
>> - struct _To_Unsigned_Type<int>
>> + struct _To_unsigned_type<int>
>> { typedef unsigned int _Type; };
>>
>> template<>
>> - struct _To_Unsigned_Type<long>
>> + struct _To_unsigned_type<long>
>> { typedef unsigned long _Type; };
>>
>> #ifdef _GLIBCXX_USE_LONG_LONG
>> template<>
>> - struct _To_Unsigned_Type<long long>
>> + struct _To_unsigned_type<long long>
>> { typedef unsigned long long _Type; };
>> #endif
>
>
>
> I think it makes sense to move these out as well. Even if they are
> only
> used in random ATM that seems to be a general concept that could be
> useful elsewhere. Following the lead of tr1::type_traits the name
> "add_unsigned" might be better, and the corresponding
> "remove_unsigned"
> could be added as well.
>
> Maybe this is even another candidate for Howard's list?
I too have needed these utilities. Fwiw I called them:
to_unsigned<T>::type;
and
to_signed<T>::type;
I note that specializations don't exist for signed/unsigned char. It
seems like that would be useful as well. But when you do that, then
remove_unsigned<unsigned char>::type -> signed char, doesn't seem to
fit as well.
-Howard
More information about the Libstdc++
mailing list