Skip to content

Latest commit

 

History

History
161 lines (109 loc) · 5.88 KB

optional-operators.md

File metadata and controls

161 lines (109 loc) · 5.88 KB
description title ms.date f1_keywords ms.assetid helpviewer_keywords
Learn more about: <optional> operators
<optional> operators
11/04/2016
optional/std::operator!=
optional/std::operator==
optional/std::operator>
optional/std::operator&gt=;
optional/std::operator<
optional/std::operator<=
57492e09-3836-4dbc-9ae5-78ecf506c190
std::operator!= (optional)
std::operator== (optional)
std::operator> (optional)
std::operator>= (optional)
std::operator< (optional)
std::`operator<=` (optional)

<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).