Re: Solid C++ by example
{To correct the funky line endings, format posts with a line length of
70 --mod}
nmm1@cam.ac.uk wrote:
A simpler and safer rule is never to use unsigned, but that isn't
feasible in C and C++.
I still think unsigneds are appropriate when used for bit masks and
manual bit
fields. They're also correct for working with UTF-8 and UTF-16, etc.
One of the more annoying historical artifacts of C and C++ is the
"randomly"
signed nature of the char type. You have to use it because strings are
based on
the char type, not explicitly signed or unsigned char, and there's no
way to
check for latent bugs in your code that will only surface if the sign of
char
randomly changes.
(Yes, I meant randomly signed instead of implementation-defined signed,
because
nothing says that the signedness cannot change from compiler to
compiler, or
compiler version to compiler version, or even based on compiler switch
settings.)
The C and C++ standards should really make char types unsigned, and drive a
stake through the heart of trigraphs. If exported templates could be set
adrift
on an ice floe, perhaps there is hope!
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]