Namespaces
Variants

operator==, !=, <, <=, >, >= (std::experimental::optional)

From cppreference.net
(Anmerkung: Der bereitgestellte HTML-Code enthält keinen übersetzbaren Text, da alle Tags leer sind. Die Struktur bleibt unverändert, wie angefordert.)
Definiert im Header <experimental/optional>
Vergleiche zwei optional Objekte
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) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator < ( const optional < T > & lhs, const optional < T > & rhs ) ;
(3) (Bibliothek Fundamentals TS)
template < class T >
constexpr bool operator <= ( const optional < T > & lhs, const optional < T > & rhs ) ;
(4) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator > ( const optional < T > & lhs, const optional < T > & rhs ) ;
(5) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator >= ( const optional < T > & lhs, const optional < T > & rhs ) ;
(6) (Library Fundamentals TS)
Vergleiche ein optional -Objekt mit einem 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) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator ! = ( std:: nullopt_t , const optional < T > & opt ) noexcept ;
(10) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator < ( const optional < T > & opt, std:: nullopt_t ) noexcept ;
(11) (Bibliotheksgrundlagen 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) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator <= ( std:: nullopt_t , const optional < T > & opt ) noexcept ;
(14) (Bibliotheksgrundlagen 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)
Vergleiche ein optional -Objekt mit einem T
template < class T >
constexpr bool operator == ( const optional < T > & opt, const T & value ) ;
(19) (Bibliotheksgrundlagen 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) (Bibliotheksgrundlagen TS)
template < class T >
constexpr bool operator ! = ( const T & value, const optional < T > & opt ) ;
(22) (Bibliothek 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) (Bibliotheksgrundlagen 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) (Bibliotheksfundamente TS)
template < class T >
constexpr bool operator > ( const T & value, const optional < T > & opt ) ;
(28) (Bibliotheksfundamente 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) (Bibliotheksfundamente TS)

Führt Vergleichsoperationen auf optional -Objekten aus.

1-6) Vergleicht zwei optional -Objekte, lhs und rhs . Die enthaltenen Werte werden nur verglichen (mittels operator == für (1,2) und operator < für (3-6) ), wenn sowohl lhs als auch rhs Werte enthalten. Andernfalls,
  • lhs wird als gleich zu rhs betrachtet, genau dann, wenn sowohl lhs als auch rhs keinen Wert enthalten.
  • lhs wird als kleiner als rhs betrachtet, genau dann, wenn rhs einen Wert enthält und lhs nicht.
7-18) Vergleicht opt mit einem nullopt . Entspricht (1-6) beim Vergleich mit einem optional , das keinen Wert enthält.
19-30) Vergleicht opt mit einem value . Die Werte werden verglichen (unter Verwendung von operator == für (19-22) und operator < für (23-30) ) nur wenn opt einen Wert enthält. Andernfalls wird opt als kleiner als value betrachtet.

Parameter

lhs, rhs, opt - ein optional Objekt zum Vergleichen
value - Wert zum Vergleich mit dem enthaltenen Wert
Typanforderungen
-
T muss die Anforderungen von EqualityComparable erfüllen, um die Überladungen (1,2) verwenden zu können.

Rückgabewert

1) Falls bool ( lhs ) ! = bool ( rhs ) , wird false zurückgegeben.
Andernfalls, falls bool ( lhs ) == false (und somit auch bool ( rhs ) == false ), gibt true zurück.
Andernfalls wird * lhs == * rhs zurückgegeben.
2) Gibt ! ( lhs == rhs ) zurück.
3) Wenn bool ( rhs ) == false zurückgibt false .
Andernfalls, falls bool ( lhs ) == false , wird true zurückgegeben.
Andernfalls wird * x < * y zurückgegeben.
4) Gibt ! ( rhs < lhs ) zurück.
5) Gibt rhs < lhs zurück.
6) Gibt ! ( lhs < rhs ) zurück.
7,8) Gibt ! opt zurück.
9,10) Gibt bool ( opt ) zurück.
11) Gibt false zurück.
12) Gibt bool ( opt ) zurück.
13) Gibt ! opt zurück.
14) Gibt true zurück.
15) Gibt bool ( opt ) zurück.
16) Gibt false zurück.
17) Gibt true zurück.
18) Gibt ! opt zurück.
19) Gibt bool ( opt ) ? * opt == value : false zurück.
20) Gibt bool ( opt ) ? value == * opt : false zurück.
21) Gibt zurück bool ( opt ) ? ! ( * opt == value ) : true .
22) Gibt zurück bool ( opt ) ? ! ( value == * opt ) : true .
23) Gibt zurück bool ( opt ) ? * opt < value : true .
24) Gibt bool ( opt ) ? value < * opt : false zurück.
25) Gibt ! ( opt > value ) zurück.
26) Gibt zurück ! ( value > opt ) .
27) Gibt bool ( opt ) ? value < * opt : false zurück.
28) Gibt bool ( opt ) ? * opt < value : true zurück.
29) Gibt ! ( opt < value ) zurück.
30) Gibt ! ( value < opt ) zurück.

Ausnahmen

1-6) (keine)
19-30) (keine)