There is only one instance where you might want to use the signed
keyword. signed char
is always a different type from "plain" char
, which may be a signed or an unsigned type depending on the implementation.
C++14 3.9.1/1 says:
It is implementation-defined whether a char
object can hold negative values. Characters can be explicitly declared unsigned
or signed
. Plain char
, signed char
, and unsigned char
are three distinct types [...]
In other contexts signed
is redundant.
Prior to C++14, (and in C), there was a second instance: bit-fields. It was implementation-defined whether, for example, int x:2;
(in the declaration of a class) is the same as unsigned int x:2;
or the same as signed int x:2
.
C++11 9.6/3 said:
It is implementation-defined whether a plain (neither explicitly signed nor unsigned) char
, short
, int
, long
, or long long
bit-field is signed or unsigned.
However, since C++14 this has been changed so that int x:2;
always means signed int
. Link to discussion
signed char
; the standard doesn't specify whether plainchar
is signed or unsigned, so if for some reason you specifically want a signed char, you have to say that explicitly. – Igor Tandetnik Jan 18 '15 at 18:02char
,signed char
andunsigned char
are three distinct types. For all other integral types,X
andsigned X
are the same. – Angew is no longer proud of SO Jan 19 '15 at 10:21signed
then you can actually drop theint
. I have no idea why one would want to do that, but it does make an occasion where the presence ofsigned
is not superfluous. – Marc van Leeuwen Jan 19 '15 at 10:27