[#bsl-basic_string-0fb-compare-063]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0fb.adoc[basic&lowbar;string&lt;char&gt;]::compare
:relfileprefix: ../../
:mrdocs:

Lexicographically compare this string with the specified `other`, and return a negative value if this string is less than `other`, a positive value if it is greater than `other`, and 0 in case of equality&period; `CHAR&lowbar;TRAITS&colon;&colon;lt` is used to compare characters&period; See &lcub;Lexicographical Comparisons&rcub;&period; The behavior is undefined unless the conversion from `STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE` to `bsl&colon;&colon;basic&lowbar;string&lowbar;view&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS&gt;` does not throw any exception&period; Note that this behavior differs from the behavior implemented in the standard container, where the following noexcept specification is used&colon; &grave; noexcept( std&colon;&colon;is&lowbar;nothrow&lowbar;convertible&lowbar;v&lt;const T&amp;, std&colon;&colon;basic&lowbar;string&lowbar;view&lt;CharT, Traits&gt; &gt;) &grave;

== Synopsis

Declared in `&lt;bslstl&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
int
compare(STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& other) const noexcept(true);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
