Re: How to elegantly get the enum code from its string type
"Keith H Duggar" <duggar@alum.mit.edu> wrote in message
news:f33199b9-6afd-4e8f-9731-d32735429874@k11g2000vbg.googlegroups.com...
I don't think anyone is advocating never using them. Most are just
trying to get people to stop confusing /un/signed with /positive/.
It's right there in the name /un/signed meaning "without sign". It
is neither positive nor negative. That is why we use them for raw
bit manipulation where we don't want /any sign/ (as in "there is
no sign") to get in the way and do unexpected things.
/un/signed is a finite modular group having no sign. Kai-UweBux's
nit not withstanding ie that their canonical C++ /representation/
is "positive" in a trivial sense. Once one stops wrongly thinking
of them as "positive" one also loses the temptation to use them
for "positive only" values.
It is not wrong at all to think of them as being "positive".
Stated with no supporting argument of course. Typical Leigh.
std::size_t is an unsigned integral type, this will not change.
std::size_t and other unsigned integral types can be used to represent
sizes
and array indexes
std::array<T>::size_type will be a typedef of std::size_t and is used
used
for array size() (always positive) and array indexes (always positive).
All of which have /nothing/ to do with them being /un/signed as
opposed to positive/negative ie "signed".
You have to accept that unsigned integral types pervade the language and
standard library so it is impossible to avoid them when writing new code.
Which again has /nothing/ to do with /un/signed != positive.
You are simply being a "use int everywhere" troll.
Where have I ever recommeneded one "use int everywhere"? (The
answer is of course "nowhere" but Leigh has a pitiable reading
comprehesion problem.)
Your position seems to be that unsigned integers should only be used for bit
manipulation and modular arithmetic, this is an incorrect position to take.
People who hold this position I refer to as "use int everywhere" trolls,
i.e. trolls who use int instead of the appropriate type and stubbornly put
forward this view in public forums. The appropriate type of "i" below is
not "int":
typedef std::vector<int> items;
....
items theItems;
....
for (items::size_type i = 0; i != theItems.size(); ++i)
{
/* do stuff with theItems[i] */
}
std::size_t has nothing to do with bit manipulation and modular arithmetic.
std::size_t pervades the language and standard library. The correct use of
unsigned integral types cannot be avoided in C++.
/Leigh