Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext
string::compare

Compare a string with the string.

Synopsis
int
compare(
    string_view sv) const noexcept;
Description

Let comp be std::char_traits<char>::compare(data(), sv.data(), std::min(size(), sv.size()). If comp != 0, then the result is comp. Otherwise, the result is 0 if size() == sv.size(), -1 if size() < sv.size(), and 1 otherwise.

Complexity

Linear.

Return Value

The result of lexicographically comparing the characters of sv and the string.

Parameters

Name

Description

sv

The string_view to compare.


PrevUpHomeNext