[#bsl-basic_string-0e-compare-0efa] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0e.adoc[basic_string<wchar_t>]::compare :relfileprefix: ../../ :mrdocs: Lexicographically compare the substring of this string of the specified `lhsNumChars` length starting at the specified `lhsPosition` (or the suffix of this string starting at `lhsPosition` if `lhsPosition + lhsNumChars > length()`) with the specified `other` string of the specified `otherNumChars` length, 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. Throw `out_of_range` if `lhsPosition > length()`. See {Lexicographical Comparisons}. == Synopsis Declared in `<bslstl_string.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int compare( xref:bsl/basic_string-0e/size_type.adoc[size_type] lhsPosition, xref:bsl/basic_string-0e/size_type.adoc[size_type] lhsNumChars, wchar_t const* other, xref:bsl/basic_string-0e/size_type.adoc[size_type] otherNumChars) const; ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#