At my code, I do not use int or unsigned int. I only use size_t or ssize_t for portable. For example:
typedef size_t intc; // (instead of unsigned int)
typedef ssize_t uintc; // (instead of int)
Because strlen
, string
, vector
... all use size_t
, so I usually use size_t
. And I only use ssize_t
when it may be negative.
But I find that:
The unsigned integer types are ideal for uses that treat storage as a bit array. Using an unsigned instead of an int to gain one more bit to represent positive integers is almost never a good idea. Attempts to ensure that some values are positive by declaring variables unsigned will typically be defeated by the implicit conversion rules.
in the book The C++ Programming Language.
So I am puzzled. Am I wrong? Why does the STL not abide by the suggest on the book?