Files
2025-10-25 03:02:53 +03:00

6.2 KiB
Raw Permalink Blame History

[optional.relops]

22 General utilities library [utilities]

22.5 Optional objects [optional]

22.5.7 Relational operators [optional.relops]

🔗

template<class T, class U> constexpr bool operator==(const optional<T>& x, const optional<U>& y);

1

#

Constraints: The expression *x == *y is well-formed and its result is convertible to bool.

[Note 1:

T need not be Cpp17EqualityComparable.

— end note]

2

#

Returns: If x.has_value() != y.has_value(), false; otherwise if x.has_value() == false, true; otherwise *x == *y.

3

#

Remarks: Specializations of this function template for which *x == *y is a core constant expression are constexpr functions.

🔗

template<class T, class U> constexpr bool operator!=(const optional<T>& x, const optional<U>& y);

4

#

Constraints: The expression *x != *y is well-formed and its result is convertible to bool.

5

#

Returns: If x.has_value() != y.has_value(), true; otherwise, if x.has_value() == false, false; otherwise *x != *y.

6

#

Remarks: Specializations of this function template for which *x != *y is a core constant expression are constexpr functions.

🔗

template<class T, class U> constexpr bool operator<(const optional<T>& x, const optional<U>& y);

7

#

Constraints: *x < *y is well-formed and its result is convertible to bool.

8

#

Returns: If !y, false; otherwise, if !x, true; otherwise *x < *y.

9

#

Remarks: Specializations of this function template for which *x < *y is a core constant expression are constexpr functions.

🔗

template<class T, class U> constexpr bool operator>(const optional<T>& x, const optional<U>& y);

10

#

Constraints: The expression *x > *y is well-formed and its result is convertible to bool.

11

#

Returns: If !x, false; otherwise, if !y, true; otherwise *x > *y.

12

#

Remarks: Specializations of this function template for which *x > *y is a core constant expression are constexpr functions.

🔗

template<class T, class U> constexpr bool operator<=(const optional<T>& x, const optional<U>& y);

13

#

Constraints: The expression *x <= *y is well-formed and its result is convertible to bool.

14

#

Returns: If !x, true; otherwise, if !y, false; otherwise *x <= *y.

15

#

Remarks: Specializations of this function template for which *x <= *y is a core constant expression are constexpr functions.

🔗

template<class T, class U> constexpr bool operator>=(const optional<T>& x, const optional<U>& y);

16

#

Constraints: The expression *x >= *y is well-formed and its result is convertible to bool.

17

#

Returns: If !y, true; otherwise, if !x, false; otherwise *x >= *y.

18

#

Remarks: Specializations of this function template for which *x >= *y is a core constant expression are constexpr functions.

🔗

template<class T, [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4Concept three_­way_­comparable[cmp.concept]")<T> U> constexpr compare_three_way_result_t<T, U> operator<=>(const optional<T>& x, const optional<U>& y);

19

#

Returns: If x && y, *x <=> *y; otherwise x.has_value() <=> y.has_value().

20

#

Remarks: Specializations of this function template for which *x <=> *y is a core constant expression are constexpr functions.