Yes, comparing std::string
s with std::string::operator>
always works. The strings are compared lexicographically. This means that each corresponding element of the two strings is compared in turn until two are found that are not equal, and that ordering determines the order of the strings.
The lexicographic ordering performs <
on each element of the std::basic_string
. That is, for a std::string
, each char
will be compared using <
. It will simply compare the values of those char
s. As far as C++ is concerned, a char
is just a numeric value. These values are mapped to the characters in a string literal by the execution character set (which, for a modern C++ compiler, is almost always at least ASCII compatible).