[#bsl-basic_string-0f3-compare-0bd] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0f3.adoc[basic_string<char32_t>]::compare :relfileprefix: ../../ :mrdocs: Lexicographically compare the substring of this string of the specified `numChars` length starting at the specified `position` (or the suffix of this string starting at `position` if `position + numChars > length()`) with the specified `other` string, and return a negative value if the indicated substring of this string is less than `other`, a positive value if it is greater than `other`, and 0 in case of equality. `CHAR_TRAITS::lt` is used to compare characters. See {Lexicographical Comparisons}. Throw `out_of_range` if `position > length()`. == Synopsis Declared in `<bslstl_string.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int compare( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars, xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>] const& other) const; ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#