Simply put, if the input is always in the same case (here, lower case), and if the characters are always ASCII, can one use string::compare to determine reliably the alphabetica
In C++, string
is the instantiation of the template class basic_string
with the default parameters: basic_string
. The compare function in the basic_string
template will use the char_traits
function to determine the result value.
For std::string
the ordering will be that of the default character code for the implementation (compiler) and that is usually ASCII order. If you require a different ordering (say you want to consider { a, á, à, â } as equivalent), you can instantiate a basic_string
with your own char_traits<>
implementation. providing a different compare
function pointer.