operator==,!=,<,<=,>,>=(std::experimental::optional) (3) - Linux Manuals
operator==,!=,<,<=,>,>=(std::experimental::optional): operator==,!=,<,<=,>,>=(std::experimental::optional)
NAME
operator==,!=,<,<=,>,>=(std::experimental::optional) - operator==,!=,<,<=,>,>=(std::experimental::optional)
Synopsis
Defined in header <experimental/optional>
Compare two optional objects
template< class T > (1) (library fundamentals TS)
constexpr bool operator==( const optional<T>& lhs, const optional<T>& rhs );
template< class T > (2) (library fundamentals TS)
constexpr bool operator!=( const optional<T>& lhs, const optional<T>& rhs );
template< class T > (3) (library fundamentals TS)
constexpr bool operator<( const optional<T>& lhs, const optional<T>& rhs );
template< class T > (4) (library fundamentals TS)
constexpr bool operator<=( const optional<T>& lhs, const optional<T>& rhs );
template< class T > (5) (library fundamentals TS)
constexpr bool operator>( const optional<T>& lhs, const optional<T>& rhs );
template< class T > (6) (library fundamentals TS)
constexpr bool operator>=( const optional<T>& lhs, const optional<T>& rhs );
Compare an optional object with a nullopt
template< class T > (7) (library fundamentals TS)
constexpr bool operator==( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (8) (library fundamentals TS)
constexpr bool operator==( std::nullopt_t, const optional<T>& opt ) noexcept;
template< class T > (9) (library fundamentals TS)
constexpr bool operator!=( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (10) (library fundamentals TS)
constexpr bool operator!=( std::nullopt_t, const optional<T>& opt ) noexcept;
template< class T > (11) (library fundamentals TS)
constexpr bool operator<( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (12) (library fundamentals TS)
constexpr bool operator<( std::nullopt_t, const optional<T>& opt ) noexcept;
template< class T > (13) (library fundamentals TS)
constexpr bool operator<=( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (14) (library fundamentals TS)
constexpr bool operator<=( std::nullopt_t, const optional<T>& opt) noexcept;
template< class T > (15) (library fundamentals TS)
constexpr bool operator>( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (16) (library fundamentals TS)
constexpr bool operator>( std::nullopt_t, const optional<T>& opt ) noexcept;
template< class T > (17) (library fundamentals TS)
constexpr bool operator>=( const optional<T>& opt, std::nullopt_t ) noexcept;
template< class T > (18) (library fundamentals TS)
constexpr bool operator>=( std::nullopt_t, const optional<T>& opt ) noexcept;
Compare an optional object with a T
template< class T > (19) (library fundamentals TS)
constexpr bool operator==( const optional<T>& opt, const T& value);
template< class T > (20) (library fundamentals TS)
constexpr bool operator==( const T& value, const optional<T>& opt );
template< class T > (21) (library fundamentals TS)
constexpr bool operator!=( const optional<T>& opt, const T& value );
template< class T > (22) (library fundamentals TS)
constexpr bool operator!=( const T& value, const optional<T>& opt );
template< class T > (23) (library fundamentals TS)
constexpr bool operator<( const optional<T>& opt, const T& value );
template< class T > (24) (library fundamentals TS)
constexpr bool operator<( const T& value, const optional<T>& opt );
template< class T > (25) (library fundamentals TS)
constexpr bool operator<=( const optional<T>& opt, const T& value );
template< class T > (26) (library fundamentals TS)
constexpr bool operator<=( const T& value, const optional<T>& opt);
template< class T > (27) (library fundamentals TS)
constexpr bool operator>( const optional<T>& opt, const T& value );
template< class T > (28) (library fundamentals TS)
constexpr bool operator>( const T& value, const optional<T>& opt );
template< class T > (39) (library fundamentals TS)
constexpr bool operator>=( const optional<T>& opt, const T& value );
template< class T > (30) (library fundamentals TS)
constexpr bool operator>=( const T& value, const optional<T>& opt );
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,
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.
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).
Return value
1) 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.
2) Returns !(lhs == rhs)
3) If bool(rhs) == false returns false
Otherwise, if bool(lhs) == false, returns true
Otherwise returns *x < *y
4) Returns !(rhs < lhs)
5) Returns rhs < lhs
6) Returns !(lhs < rhs)
7-8) Returns !opt.
9-10) Returns bool(opt).
11) Returns false.
12) Returns bool(opt).
13) Returns !opt.
14) Returns true.
15) Returns bool(opt).
16) Returns false.
17) Returns true.
18) Returns !opt.
19) Returns bool(opt) ? *opt == value : false.
20) Returns bool(opt) ? value == *opt : false.
21) Returns bool(opt) ? !(*opt == value) : true.
22) Returns bool(opt) ? !(value == *opt) : true.
23) Returns bool(opt) ? *opt < value : true.
24) Returns bool(opt) ? value < *opt : false.
25) Returns !(opt > value).
26) Returns !(value > opt).
27) Returns bool(opt) ? value < *opt : false.
28) Returns bool(opt) ? *opt < value : true.
29) Returns !(opt < value).
30) Returns !(value < opt).
Exceptions
1-6) (none)
19-30) (none)