Muokkaa

Jaa


<optional> operators

operator==

Tests if the optional object on the left side of the operator is equal to the optional object on the right side.

template <class T, class U> constexpr bool operator==(const optional<T>& left, const optional<U>& right);
template <class T> constexpr bool operator==(const optional<T>& left, nullopt_t right) noexcept;
template <class T> constexpr bool operator==(nullopt_t left, const optional<T>& right) noexcept;
template <class T, class U> constexpr bool operator==(const optional<T>&, const U&);
template <class T, class U> constexpr bool operator==(const U&, const optional<T>&);

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

operator!=

Tests if the optional object on the left side of the operator is not equal to the optional object on the right side.

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

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

Remarks

This template function returns !(left == right).

operator<

Tests if the optional object on the left side of the operator is less than the optional object on the right side.

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

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

Return Value

true if the list on the left side of the operator is less than but not equal to the list on the right side of the operator; otherwise false.

operator<=

Tests if the optional object on the left side of the operator is less than or equal to the optional object on the right side.

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

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

Return Value

true if the list on the left side of the operator is less than or equal to the list on the right side of the operator; otherwise false.

Remarks

This template function returns !(right < left).

operator>

Tests if the optional object on the left side of the operator is greater than the optional object on the right side.

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

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

Return Value

true if the list on the left side of the operator is greater than the list on the right side of the operator; otherwise false.

Remarks

This template function returns right < left.

operator>=

Tests if the optional object on the left side of the operator is greater than or equal to the optional object on the right side.

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

Parameters

left
An object of type optional, nullopt_t, or T.

right
An object of type optional, nullopt_t, or T.

Return Value

true if the optional on the left side of the operator is greater than or equal to the optional on the right side of the operator; otherwise false.

Remarks

The template function returns !(left < right).