[#beman-optional-operator_3way-04] = xref:beman.adoc[beman]::xref:beman/optional.adoc[optional]::operator<=> :relfileprefix: ../../ :mrdocs: Three‐way comparison operators == Synopses Declared in `<beman/optional/optional.hpp>` Compares two `nullopt_t` objects. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr std::strong_ordering xref:beman/optional/operator_3way-0a.adoc[operator<=>]( xref:beman/optional/nullopt_t.adoc[nullopt_t] lhs, xref:beman/optional/nullopt_t.adoc[nullopt_t] rhs) noexcept; ---- [.small]#xref:beman/optional/operator_3way-0a.adoc[_» more..._]# Three‐way comparison of two optionals. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename T, std::three_way_comparable_with<T> U> constexpr std::compare_three_way_result_t<T, U> xref:beman/optional/operator_3way-09.adoc[operator<=>]( xref:beman/optional/optional-03.adoc[optional<T>] const& lhs, xref:beman/optional/optional-03.adoc[optional<U>] const& rhs); ---- [.small]#xref:beman/optional/operator_3way-09.adoc[_» more..._]# Three‐way comparison of an optional against `nullopt`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class T> constexpr std::strong_ordering xref:beman/optional/operator_3way-05.adoc[operator<=>]( xref:beman/optional/optional-03.adoc[optional<T>] const& lhs, xref:beman/optional/nullopt_t.adoc[nullopt_t] rhs) noexcept; ---- [.small]#xref:beman/optional/operator_3way-05.adoc[_» more..._]# Three‐way comparison of an optional against a value. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename T, typename U> requires (!is_derived_from_optional<U>) && std::three_way_comparable_with<T, U> constexpr std::compare_three_way_result_t<T, U> xref:beman/optional/operator_3way-08.adoc[operator<=>]( xref:beman/optional/optional-03.adoc[optional<T>] const& x, U const& v); ---- [.small]#xref:beman/optional/operator_3way-08.adoc[_» more..._]# == Return Value * Always `std::strong_ordering::equivalent`, since all `nullopt_t` objects compare equal. * The comparison category; a disengaged optional orders before any engaged one. * `equivalent` if `lhs` is disengaged, otherwise `greater`. * The comparison category; a disengaged optional orders before `v.` == Parameters [cols="1,4"] |=== | Name| Description | *lhs* | The left‐hand `nullopt_t` object. | *rhs* | The right‐hand `nullopt_t` object. | *x* | The optional operand. | *v* | The value operand. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#