FastLED 3.9.15
Loading...
Searching...
No Matches

◆ compare() [4/6]

int fl::basic_string::compare ( fl::size pos1,
fl::size count1,
const basic_string & str,
fl::size pos2,
fl::size count2 = npos ) const

Definition at line 1129 of file basic_string.cpp.hpp.

1130 {
1131 if (pos1 > mLength || pos2 >= str.size()) {
1132 if (pos1 > mLength && pos2 >= str.size()) return 0;
1133 if (pos1 > mLength) return -1;
1134 return 1;
1135 }
1136 fl::size actualCount1 = count1;
1137 if (actualCount1 == npos || pos1 + actualCount1 > mLength) {
1138 actualCount1 = mLength - pos1;
1139 }
1140 fl::size actualCount2 = count2;
1141 if (actualCount2 == npos || pos2 + actualCount2 > str.size()) {
1142 actualCount2 = str.size() - pos2;
1143 }
1144 fl::size minLen = (actualCount1 < actualCount2) ? actualCount1 : actualCount2;
1145 int result = fl::strncmp(c_str() + pos1, str.c_str() + pos2, minLen);
1146 if (result != 0) return result;
1147 if (actualCount1 < actualCount2) return -1;
1148 if (actualCount1 > actualCount2) return 1;
1149 return 0;
1150}
static constexpr fl::size npos
const char * c_str() const FL_NOEXCEPT
int strncmp(const char *s1, const char *s2, size_t n) FL_NOEXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References basic_string(), c_str(), mLength, npos, size(), and fl::strncmp().

+ Here is the call graph for this function: