[#bsl-basic_string-0faf-compare-0f] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic_string]::compare :relfileprefix: ../../ :mrdocs: Lexicographically compare this string with another sequence. == Synopses Declared in `<bslstl_string.h>` Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-057.adoc[compare](xref:bsl/basic_string-0faf.adoc[basic_string] const& other) const noexcept; ---- [.small]#xref:bsl/basic_string-0faf/compare-057.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-08.adoc[compare](CHAR_TYPE const* other) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-08.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> int xref:bsl/basic_string-0faf/compare-0c.adoc[compare](STRING_VIEW_LIKE_TYPE const& other) const noexcept(true); ---- [.small]#xref:bsl/basic_string-0faf/compare-0c.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-0b.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsNumChars, CHAR_TYPE const* other) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-0b.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-050.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, xref:bsl/basic_string-0faf.adoc[basic_string] const& other) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-050.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> int xref:bsl/basic_string-0faf/compare-0d.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf/size_type.adoc[size_type] numChars, STRING_VIEW_LIKE_TYPE const& other) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-0d.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-07.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsNumChars, CHAR_TYPE const* other, xref:bsl/basic_string-0faf/size_type.adoc[size_type] otherNumChars) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-07.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int xref:bsl/basic_string-0faf/compare-06.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsNumChars, xref:bsl/basic_string-0faf.adoc[basic_string] const& other, xref:bsl/basic_string-0faf/size_type.adoc[size_type] otherPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] otherNumChars = npos) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-06.adoc[_» more..._]# Lexicographically compare this string with another sequence. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> int xref:bsl/basic_string-0faf/compare-053.adoc[compare]( xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] lhsNumChars, STRING_VIEW_LIKE_TYPE const& other, xref:bsl/basic_string-0faf/size_type.adoc[size_type] otherPosition, xref:bsl/basic_string-0faf/size_type.adoc[size_type] otherNumChars = npos) const; ---- [.small]#xref:bsl/basic_string-0faf/compare-053.adoc[_» more..._]# == Return Value negative, zero, or positive according to the lexicographic order == Parameters [cols="1,4"] |=== | Name| Description | *other* | string or character sequence to compare or use | *lhsPosition* | starting index of the left‐hand substring | *lhsNumChars* | length of the left‐hand substring | *position* | starting index | *numChars* | number of characters | *otherNumChars* | length of the other substring | *otherPosition* | starting index in the other string |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#