operator==, !=, <, <=, >, >=(std::experimental::optional) (original) (raw)
Defined in header <experimental/optional> | ||
---|---|---|
Compare two optional objects | ||
template< class T > constexpr bool operator==( const optional<T>& lhs, const optional<T>& rhs ); | (1) | (library fundamentals TS) |
template< class T > constexpr bool operator!=( const optional<T>& lhs, const optional<T>& rhs ); | (2) | (library fundamentals TS) |
template< class T > constexpr bool operator<( const optional<T>& lhs, const optional<T>& rhs ); | (3) | (library fundamentals TS) |
template< class T > constexpr bool operator<=( const optional<T>& lhs, const optional<T>& rhs ); | (4) | (library fundamentals TS) |
template< class T > constexpr bool operator>( const optional<T>& lhs, const optional<T>& rhs ); | (5) | (library fundamentals TS) |
template< class T > constexpr bool operator>=( const optional<T>& lhs, const optional<T>& rhs ); | (6) | (library fundamentals TS) |
Compare an optional object with a nullopt | ||
template< class T > constexpr bool operator==( const optional<T>& opt, std::nullopt_t ) noexcept; | (7) | (library fundamentals TS) |
template< class T > constexpr bool operator==( std::nullopt_t, const optional<T>& opt ) noexcept; | (8) | (library fundamentals TS) |
template< class T > constexpr bool operator!=( const optional<T>& opt, std::nullopt_t ) noexcept; | (9) | (library fundamentals TS) |
template< class T > constexpr bool operator!=( std::nullopt_t, const optional<T>& opt ) noexcept; | (10) | (library fundamentals TS) |
template< class T > constexpr bool operator<( const optional<T>& opt, std::nullopt_t ) noexcept; | (11) | (library fundamentals TS) |
template< class T > constexpr bool operator<( std::nullopt_t, const optional<T>& opt ) noexcept; | (12) | (library fundamentals TS) |
template< class T > constexpr bool operator<=( const optional<T>& opt, std::nullopt_t ) noexcept; | (13) | (library fundamentals TS) |
template< class T > constexpr bool operator<=( std::nullopt_t, const optional<T>& opt ) noexcept; | (14) | (library fundamentals TS) |
template< class T > constexpr bool operator>( const optional<T>& opt, std::nullopt_t ) noexcept; | (15) | (library fundamentals TS) |
template< class T > constexpr bool operator>( std::nullopt_t, const optional<T>& opt ) noexcept; | (16) | (library fundamentals TS) |
template< class T > constexpr bool operator>=( const optional<T>& opt, std::nullopt_t ) noexcept; | (17) | (library fundamentals TS) |
template< class T > constexpr bool operator>=( std::nullopt_t, const optional<T>& opt ) noexcept; | (18) | (library fundamentals TS) |
Compare an optional object with a T | ||
template< class T > constexpr bool operator==( const optional<T>& opt, const T& value ); | (19) | (library fundamentals TS) |
template< class T > constexpr bool operator==( const T& value, const optional<T>& opt ); | (20) | (library fundamentals TS) |
template< class T > constexpr bool operator!=( const optional<T>& opt, const T& value ); | (21) | (library fundamentals TS) |
template< class T > constexpr bool operator!=( const T& value, const optional<T>& opt ); | (22) | (library fundamentals TS) |
template< class T > constexpr bool operator<( const optional<T>& opt, const T& value ); | (23) | (library fundamentals TS) |
template< class T > constexpr bool operator<( const T& value, const optional<T>& opt ); | (24) | (library fundamentals TS) |
template< class T > constexpr bool operator<=( const optional<T>& opt, const T& value ); | (25) | (library fundamentals TS) |
template< class T > constexpr bool operator<=( const T& value, const optional<T>& opt ); | (26) | (library fundamentals TS) |
template< class T > constexpr bool operator>( const optional<T>& opt, const T& value ); | (27) | (library fundamentals TS) |
template< class T > constexpr bool operator>( const T& value, const optional<T>& opt ); | (28) | (library fundamentals TS) |
template< class T > constexpr bool operator>=( const optional<T>& opt, const T& value ); | (29) | (library fundamentals TS) |
template< class T > constexpr bool operator>=( const T& value, const optional<T>& opt ); | (30) | (library fundamentals TS) |
Performs comparison operations on optional
objects.
1-6) Compares two optional
objects, lhs and rhs. The contained values are compared (using operator== for (1,2) and operator< for (3-6)) only if both lhs and rhs contain values. Otherwise,
- lhs is considered equal to rhs if, and only if, both lhs and rhs do not contain a value.
- lhs is considered less than rhs if, and only if, rhs contains a value and lhs does not.
7-18) Compares opt with a nullopt. Equivalent to (1-6) when comparing to an optional
that does not contain a value.
19-30) Compares opt with a value. The values are compared (using operator== for (19-22) and operator< for (23-30)) only if opt contains a value. Otherwise, opt is considered less than value.
[edit] Parameters
lhs, rhs, opt | - | an optional object to compare |
---|---|---|
value | - | value to compare to the contained value |
Type requirements | ||
-T must meet the requirements of EqualityComparable in order to use overloads (1,2). |
[edit] Return value
- If bool(lhs) != bool(rhs), returns false.
Otherwise, if bool(lhs) == false (and so bool(rhs) == false as well), returns true.
Otherwise, returns *lhs == *rhs.
Returns !(lhs == rhs).
If bool(rhs) == false returns false.
Otherwise, if bool(lhs) == false, returns true.
Otherwise returns *x < *y.
Returns !(rhs < lhs).
Returns rhs < lhs.
Returns !(lhs < rhs).
7,8) Returns !opt.
9,10) Returns bool(opt).
Returns false.
Returns bool(opt).
Returns !opt.
Returns true.
Returns bool(opt).
Returns false.
Returns true.
Returns !opt.
Returns bool(opt) ? *opt == value : false.
Returns bool(opt) ? value == *opt : false.
Returns bool(opt) ? !(*opt == value) : true.
Returns bool(opt) ? !(value == *opt) : true.
Returns bool(opt) ? *opt < value : true.
Returns bool(opt) ? value < *opt : false.
Returns !(opt > value).
Returns !(value > opt).
Returns bool(opt) ? value < *opt : false.
Returns bool(opt) ? *opt < value : true.
Returns !(opt < value).
Returns !(value < opt).
[edit] Exceptions
1-6) (none)
19-30) (none)