...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Compare a string with the string.
constexpr int compare( size_type pos1, size_type count1, const_pointer s, size_type count2) const;
Let sub
be substr(pos1, count1)
,
and comp
be traits_type::compare(sub.data(), s, std::min(size(), count2)
.
If comp !=
0
, then the result is comp
. Otherwise, the result is 0
if sub.size() == count2
, -1
if sub.size() < count2
, and 1
otherwise.
Linear.
Strong guarantee.
The result of lexicographically comparing s
and sub
.
Name |
Description |
---|---|
|
The index at which to begin the substring. |
|
The size of the substring. |
|
The string to compare. |
|
The length of the string to compare. |
Type |
Thrown On |
---|---|
|
pos1 > |