bsl::basic_string::compare

Lexicographically compare this string with another sequence.

Synopses

Declared in <bslstl_string.h>

Lexicographically compare this string with another sequence.

int
compare(basic_string const& other) const noexcept;
» more...

Lexicographically compare this string with another sequence.

int
compare(CHAR_TYPE const* other) const;
» more...

Lexicographically compare this string with another sequence.

template<class STRING_VIEW_LIKE_TYPE>
int
compare(STRING_VIEW_LIKE_TYPE const& other) const noexcept(true);
» more...

Lexicographically compare this string with another sequence.

int
compare(
    size_type lhsPosition,
    size_type lhsNumChars,
    CHAR_TYPE const* other) const;
» more...

Lexicographically compare this string with another sequence.

int
compare(
    size_type position,
    size_type numChars,
    basic_string const& other) const;
» more...

Lexicographically compare this string with another sequence.

template<class STRING_VIEW_LIKE_TYPE>
int
compare(
    size_type position,
    size_type numChars,
    STRING_VIEW_LIKE_TYPE const& other) const;
» more...

Lexicographically compare this string with another sequence.

int
compare(
    size_type lhsPosition,
    size_type lhsNumChars,
    CHAR_TYPE const* other,
    size_type otherNumChars) const;
» more...

Lexicographically compare this string with another sequence.

int
compare(
    size_type lhsPosition,
    size_type lhsNumChars,
    basic_string const& other,
    size_type otherPosition,
    size_type otherNumChars = npos) const;
» more...

Lexicographically compare this string with another sequence.

template<class STRING_VIEW_LIKE_TYPE>
int
compare(
    size_type lhsPosition,
    size_type lhsNumChars,
    STRING_VIEW_LIKE_TYPE const& other,
    size_type otherPosition,
    size_type otherNumChars = npos) const;
» more...

Return Value

negative, zero, or positive according to the lexicographic order

Parameters

NameDescription
otherstring or character sequence to compare or use
lhsPositionstarting index of the left-hand substring
lhsNumCharslength of the left-hand substring
positionstarting index
numCharsnumber of characters
otherNumCharslength of the other substring
otherPositionstarting index in the other string