<optional>
運算子
operator==
測試運算子左邊的 optional
物件是否等於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
operator!=
測試運算子左邊的 optional
物件是否不等於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
備註
此範本函式會傳回 !(left == right)
。
operator<
測試運算子左邊的 optional
物件是否小於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
傳回值
若運算子左邊的清單小於但不等於右邊的清單,即為 true
;否則為 false
。
operator<=
測試運算子左邊的 optional
物件是否小於或等於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
傳回值
若運算子左邊的清單小於或等於右邊的清單,即為 true
;否則為 false
。
備註
此範本函式會傳回 !(right < left)
。
operator>
測試運算子左邊的 optional
物件是否大於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
傳回值
如果運算子左邊的清單大於右邊的清單,即為 true
;否則為 false
。
備註
此範本函式會傳回 right < left
。
operator>=
測試運算子左邊的 optional
物件是否大於或等於右邊的 optional
物件。
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>&);
參數
left
型 optional
別為、 nullopt_t
或 T
的物件。
right
型 optional
別為、 nullopt_t
或 T
的物件。
傳回值
true
optional
如果運算子左邊的 大於或等於optional
運算子右邊的 ,則為 ,否則false
為 。
備註
此範本函式會傳回 !(left < right)
。