Re: How to elegantly get the enum code from its string type
On Apr 15, 12:15 am, "Leigh Johnston" <le...@i42.co.uk> wrote:
"James Kanze" <james.ka...@gmail.com> wrote in message
news:b957812e-e4e3-47be-a591-156e6224e99a@g30g2000yqc.googlegroups.com...
More generally, unsigned types, in C++, are not cardinal
numbers, but have very special (and somewhat curious)
semantics. You use them in two cases: when you're doing bit
manipulations, and unsigned char for raw memory. (Plus the
very rare case where you actually want the special
semantics---calculating hash codes is the only case which
comes to mind.)
Sorry James but you are spouting garbage again. One word: size_t.
So who uses size_t on a modern machine?
Back when C was being standardize, 16 bit machines were still
legion, and the extra bit was necessary. Today, realistically,
size_t is an anachronism, and not really necessary. (It's worth
noting that the STL was originally developed using Borland C++,
on a 16 bit machine. Which possibly accounts for it's use of
unsigned size_type as well.)
Even today, size_t is designed to support the very lowest level
of programming, and there are contexts (e.g. writing a garbage
collector) where you really do need that extra bit. (A garbage
collector on a 32 bit machine has to handle memory blocks which
are larger than 2GB.) But you don't normally use it in
application level code, except to avoid signed/unsigned
comparison warnings when using the STL.
--
James Kanze