Strings are always compared as unsigned char regardless of the sign of the actual character.
std::string took this behavior with C, where strcmp uses characters in the range 0-255, even if char is in the range -128 - 127.
So basically -70 - 186 and 186> 'a'
Edit: Link to standard. I don't have C ++ 98/2003 next to me, only C ++ 0x, but:
βWorking draft, standard for the C ++ programming languageβ, N2915, 21.2.3.1, note 5 states:
Elements with two arguments eq and lt must be defined identically to the built-in operations == and <for type unsigned char.
i.e. characters are compared as unsigned char. (he refers to character traits specialization for char)
source share