[#beman-optional-operator_3way-04]
= xref:beman.adoc[beman]::xref:beman/optional.adoc[optional]::operator&lt;&equals;&gt;
:relfileprefix: ../../
:mrdocs:

Three&hyphen;way comparison operators

== Synopses

Declared in `&lt;beman&sol;optional&sol;optional&period;hpp&gt;`

Compares two `nullopt&lowbar;t` objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
std::strong&lowbar;ordering
xref:beman/optional/operator_3way-0a.adoc[operator&lt;&equals;&gt;](
    xref:beman/optional/nullopt_t.adoc[nullopt&lowbar;t] lhs,
    xref:beman/optional/nullopt_t.adoc[nullopt&lowbar;t] rhs) noexcept;
----

[.small]#xref:beman/optional/operator_3way-0a.adoc[_» more&period;&period;&period;_]#

Three&hyphen;way comparison of two optionals&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    std::three&lowbar;way&lowbar;comparable&lowbar;with&lt;T&gt; U&gt;
constexpr
std::compare&lowbar;three&lowbar;way&lowbar;result&lowbar;t&lt;T, U&gt;
xref:beman/optional/operator_3way-09.adoc[operator&lt;&equals;&gt;](
    xref:beman/optional/optional-03.adoc[optional&lt;T&gt;] const& lhs,
    xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs);
----

[.small]#xref:beman/optional/operator_3way-09.adoc[_» more&period;&period;&period;_]#

Three&hyphen;way comparison of an optional against `nullopt`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
constexpr
std::strong&lowbar;ordering
xref:beman/optional/operator_3way-05.adoc[operator&lt;&equals;&gt;](
    xref:beman/optional/optional-03.adoc[optional&lt;T&gt;] const& lhs,
    xref:beman/optional/nullopt_t.adoc[nullopt&lowbar;t] rhs) noexcept;
----

[.small]#xref:beman/optional/operator_3way-05.adoc[_» more&period;&period;&period;_]#

Three&hyphen;way comparison of an optional against a value&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    typename U&gt;
requires (!is&lowbar;derived&lowbar;from&lowbar;optional&lt;U&gt;) &amp;&amp; std&colon;&colon;three&lowbar;way&lowbar;comparable&lowbar;with&lt;T, U&gt;
constexpr
std::compare&lowbar;three&lowbar;way&lowbar;result&lowbar;t&lt;T, U&gt;
xref:beman/optional/operator_3way-08.adoc[operator&lt;&equals;&gt;](
    xref:beman/optional/optional-03.adoc[optional&lt;T&gt;] const& x,
    U const& v);
----

[.small]#xref:beman/optional/operator_3way-08.adoc[_» more&period;&period;&period;_]#

== Return Value

* Always `std&colon;&colon;strong&lowbar;ordering&colon;&colon;equivalent`, since all `nullopt&lowbar;t` objects compare equal&period;
* The comparison category&semi; a disengaged optional orders before any engaged one&period;
* `equivalent` if `lhs` is disengaged, otherwise `greater`&period;
* The comparison category&semi; a disengaged optional orders before `v&period;`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *lhs*
| The left&hyphen;hand `nullopt&lowbar;t` object&period;
| *rhs*
| The right&hyphen;hand `nullopt&lowbar;t` object&period;
| *x*
| The optional operand&period;
| *v*
| The value operand&period;
|===


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