...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.
template< typename T> constexpr int compare( const T& t) const;
Let s
be string_view_type(t)
and comp
be traits_type::compare(data(), s.data(), std::min(size(), s.size())
.
If comp !=
0
, then the result is comp
. Otherwise, the result is 0
if size() == s.size()
,
-1
if size()
< s.size()
, and 1
otherwise.
Linear.
Strong guarantee.
Type |
Description |
---|---|
|
The type of the object to convert. |
std::is_convertible<const T&, string_view>::value && !std::is_convertible<const T&, const_pointer>::value.
The result of lexicographically comparing s
and the string.
Name |
Description |
---|---|
|
The string to compare. |