Length-aware lexicographic compare. Doesn't rely on strcmp's NUL-termination, so view-backed strings (`setView`) and any future embedded-NUL content compare correctly. Returns the same sign convention as memcmp / strcmp.
| 209 | // future embedded-NUL content compare correctly. Returns the same |
| 210 | // sign convention as memcmp / strcmp. |
| 211 | static inline int string_compare(const string& a, const string& b) FL_NOEXCEPT { |
| 212 | fl::size n = (a.size() < b.size()) ? a.size() : b.size(); |
| 213 | int r = fl::memcmp(a.c_str(), b.c_str(), n); |
| 214 | if (r != 0) return r; |
| 215 | if (a.size() < b.size()) return -1; |
| 216 | if (a.size() > b.size()) return 1; |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | bool string::operator>(const string& other) const FL_NOEXCEPT { |
| 221 | return string_compare(*this, other) > 0; |
no test coverage detected