Are strings compared lexicographical when using the overriden bool operator<(const std::string & rhs) operator? In example:
std::string str1 = "aabbcc"
std::string str2 = "bbaacc"
(str1 < str2) == std::lexicographical_compare(str1.begin(),str1.end(),str2.begin(),str2.end()) // is this statement true?
Yes.
String’s comparison operators are defined in terms of its
traits::compare(that ischar_traits<char>::compare) (C++03 21.3.6.8) which is specified to return a value based on the lexicographical ordering of its arguments (21.1.1).In effect, it means comparing string must not be locale sensitive (which could be non-lexicographical in some locales, such as mine).