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

Equality operators

== Synopses

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

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


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
bool
xref:beman/optional/operator_eq-03.adoc[operator&equals;&equals;](
    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_eq-03.adoc[_» more&period;&period;&period;_]#

Compares two optionals for equality&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    typename U&gt;
constexpr
bool
xref:beman/optional/operator_eq-08.adoc[operator&equals;&equals;](
    xref:beman/optional/optional-03.adoc[optional&lt;T&gt;] const& lhs,
    xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs)
requires detail&colon;&colon;optional&lowbar;eq&lowbar;rel&lt;T, U&gt;;
----

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

Compares an optional against `nullopt`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
constexpr
bool
xref:beman/optional/operator_eq-00.adoc[operator&equals;&equals;](
    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_eq-00.adoc[_» more&period;&period;&period;_]#

Compares an engaged optional&apos;s value against a value for equality&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    typename U&gt;
constexpr
bool
xref:beman/optional/operator_eq-09.adoc[operator&equals;&equals;](
    xref:beman/optional/optional-03.adoc[optional&lt;T&gt;] const& lhs,
    U const& rhs)
requires (!detail&colon;&colon;is&lowbar;optional&lt;U&gt;) &amp;&amp; detail&colon;&colon;optional&lowbar;eq&lowbar;rel&lt;T, U&gt;;
----

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

Compares a value against an engaged optional&apos;s value for equality&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    typename U&gt;
constexpr
bool
xref:beman/optional/operator_eq-0b.adoc[operator&equals;&equals;](
    T const& lhs,
    xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs)
requires (!detail&colon;&colon;is&lowbar;optional&lt;T&gt;) &amp;&amp; detail&colon;&colon;optional&lowbar;eq&lowbar;rel&lt;T, U&gt;;
----

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

== Return Value

* Always `true`, since all `nullopt&lowbar;t` objects compare equal&period;
* `true` if both are disengaged, or both are engaged and their contained values are equal&period;
* `true` if `lhs` is disengaged&period;
* `true` if `lhs` is engaged and its contained value equals `rhs&period;`
* `true` if `rhs` is engaged and `lhs` equals its contained value&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;
|===


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