basic_string::compare
basic_string::compare
int compare(const basic_string& str) const;
int compare(size_type p0, size_type n0,
const basic_string& str);
int compare(size_type p0, size_type n0,
const basic_string& str, size_type pos, size_type n);
int compare(const E *s) const;
int compare(size_type p0, size_type n0,
const E *s) const;
int compare(size_type p0, size_type n0,
const E *s, size_type pos) const;
Each member function compares up to n0
elements of the controlled sequence beginning with position p0
, or the entire controlled sequence if these arguments are not supplied, to the operand sequence. The function returns:
- A negative value if the first differing element in the controlled sequence compares less than the corresponding element in the operand sequence (as determined by
T::
compare
), or if the two have a common prefix but the operand sequence is longer. - Zero if the two compare equal element by element and are the same length.
- A positive value otherwise.