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

8.1 KiB
Raw Permalink Blame History

[optional.comp.with.t]

22 General utilities library [utilities]

22.5 Optional objects [optional]

22.5.9 Comparison with T [optional.comp.with.t]

🔗

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

1

#

Constraints: U is not a specialization of optional.

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

[Note 1:

T need not be Cpp17EqualityComparable.

— end note]

2

#

Effects: Equivalent to: return x.has_value() ? *x == v : false;

🔗

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

3

#

Constraints: T is not a specialization of optional.

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

4

#

Effects: Equivalent to: return x.has_value() ? v == *x : false;

🔗

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

5

#

Constraints: U is not a specialization of optional.

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

6

#

Effects: Equivalent to: return x.has_value() ? *x != v : true;

🔗

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

7

#

Constraints: T is not a specialization of optional.

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

8

#

Effects: Equivalent to: return x.has_value() ? v != *x : true;

🔗

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

9

#

Constraints: U is not a specialization of optional.

The expression *x < v is well-formed and its result is convertible to bool.

10

#

Effects: Equivalent to: return x.has_value() ? *x < v : true;

🔗

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

11

#

Constraints: T is not a specialization of optional.

The expression v < *x is well-formed and its result is convertible to bool.

12

#

Effects: Equivalent to: return x.has_value() ? v < *x : false;

🔗

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

13

#

Constraints: U is not a specialization of optional.

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

14

#

Effects: Equivalent to: return x.has_value() ? *x > v : false;

🔗

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

15

#

Constraints: T is not a specialization of optional.

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

16

#

Effects: Equivalent to: return x.has_value() ? v > *x : true;

🔗

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

17

#

Constraints: U is not a specialization of optional.

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

18

#

Effects: Equivalent to: return x.has_value() ? *x <= v : true;

🔗

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

19

#

Constraints: T is not a specialization of optional.

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

20

#

Effects: Equivalent to: return x.has_value() ? v <= *x : false;

🔗

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

21

#

Constraints: U is not a specialization of optional.

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

22

#

Effects: Equivalent to: return x.has_value() ? *x >= v : false;

🔗

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

23

#

Constraints: T is not a specialization of optional.

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

24

#

Effects: Equivalent to: return x.has_value() ? v >= *x : true;

🔗

template<class T, class U> requires (![is-derived-from-optional](optional.syn#concept:is-derived-from-optional "22.5.2Header <optional> synopsis[optional.syn]")<U>) && [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 U& v);

25

#

Effects: Equivalent to: return x.has_value() ? *x <=> v : strong_ordering::less;