[v3] ext/type_traits.h
Paolo Carlini
pcarlini@suse.de
Mon Sep 25 08:47:00 GMT 2006
Benjamin Kosnik wrote:
>>I want to say that whereas, per your citation, I also called the trait
>>to_* when I "invented" ;) it, the new naming scheme may have advantages:
>>we are directing attention to the syntactic notion of adding the
>>""unsigned qualification"" or removing it, not to the actual signedness
>>of the types at issue in input and output (I hope I'm sufficiently
>>clear).
>>
>>
>I think so.
>
Ok...
> FYI this is the reason I think __add_unsigned is better than __add_signed.
>
>
... but isn't __add_signed necessary anyway, from out point of view?
Imean, we would have,
template<typename _Value>
struct __add_signed
{ typedef _Value __type; };
template<>
struct __add_signed<char>
{ typedef signed char __type; };
...
template<typename _Value>
struct __remove_signed
{ typedef _Value __type; };
template<>
struct __remove_signed<signed char>
{ typedef char __type; };
...
Indeed, for short, int, and so on, the ""signed qualifier"" is implicit
(I thnink that was your point), from a semantic point of view, but
syntactically, our route in fact, only adding both appear to lead to a
consistent and complete set. About the latter, I was thinking yesterday,
that, if I'm not mistaken, we could also have:
template<typename _Value>
struct __to_signed
{
typedef typename
__add_signed<typename
__remove_unsigned<_Value>::__type>::__type __type;
};
template<typename _Value>
struct __to_unsigned
{
typedef typename
__add_unsigned<typename
__remove_signed<_Value>::__type>::__type __type;
};
Paolo.
More information about the Libstdc++
mailing list