Compares two character sequences.
rlen
of the sequences to compare is the smaller of size()
and v.size()
. The function compares the two views by calling traits::compare(data(), v.data(), rlen)
, and returns a value according to the following table:Condition | Result | Return value | |
---|---|---|---|
Traits::compare(data(), v.data(), rlen) < 0 | this is less than v | <0 |
|
Traits::compare(data(), v.data(), rlen) == 0 | size() < v.size() | this is less than v | <0 |
size() == v.size() | this is equal to v | 0 |
|
size() > v.size() | this is greater than v | >0 |
|
Traits::compare(data(), v.data(), rlen) > 0 | this is greater than v | >0 |
substr(pos1, count1).compare(v)
.substr(pos1, count1).compare(v.substr(pos2, count2))
.compare(basic_string_view(s))
.substr(pos1, count1).compare(basic_string_view(s))
.substr(pos1, count1).compare(basic_string_view(s, count2))
.v | - | view to compare |
s | - | pointer to the character string to compare to |
count1 | - | number of characters of this view to compare |
pos1 | - | position of the first character in this view to compare |
count2 | - | number of characters of the given view to compare |
pos2 | - | position of the first character of the given view to compare |
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.
1) Linear in the number of characters compared.
lexicographically compares two string views (function template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/string/basic_string_view/compare