This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] ext/type_traits.h
> I just looked at the latest version of __add_unsigned in ext/
> type_traits.h. The above (very reasonable) recipe breaks for signed
> char. I see no way to turn a signed char into an unsigned char. If
> add_unsigned<signed char>::type would deliver an unsigned char
> instead of a signed char, then I think we would be set.
Got it, thanks. I always forget about signed char, unsigned char, and char.
> Similarly, both remove_unsigned<unsigned char>::type and
> remove_unsigned<char>::type should probably yield signed char instead
> of char, at least when char is unsigned. I'd hate to say
> remove_unsigned<char>::type and get an unsigned type.
Yep.
> With those changes, we don't even need your suggested recipe using
> conditional_type:
>
> // To get unsigned type.
> add_unsigned<T>::type
>
> The condition is built into add_unsigned.
Nice.
I'll add this in, with tests.
Thanks!
-benjamin