CopperSpice API
1.9.2
|
Stores a pair of items. More...
Public Typedefs | |
using | first_type = T1 |
using | second_type = T2 |
Public Methods | |
QPair () | |
QPair (const QPair &other) = default | |
QPair (const T1 &value1, const T2 &value2) | |
QPair (QPair &&other) = default | |
QPair< T1, T2 > & | operator= (const QPair< T1, T2 > &other) = default |
QPair< T1, T2 > & | operator= (QPair< T1, T2 > &&other) = default |
void | swap (QPair &other) |
Public Members | |
T1 | first |
T2 | second |
Related Functions | |
These are not member functions | |
bool | operator!= (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
bool | operator< (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
QDataStream & | operator<< (QDataStream &stream, const QPair< T1, T2 > &pair) |
bool | operator<= (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
bool | operator== (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
bool | operator> (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
bool | operator>= (const QPair< T1, T2 > &p1, const QPair< T1, T2 > &p2) |
QDataStream & | operator>> (QDataStream &stream, QPair< T1, T2 > &pair) |
QPair< T1, T2 > | qMakePair (const T1 &value1, const T2 &value2) |
The QPair class is a class which stores a pair of items. It stores one value of type T1 and one value of type T2. QPair can be used as a return value for a method which returns two values or as the value type of a generic container.
The following is an example of a QPair which stores a QString and a double
value.
The components are accessible as public data members called first and second.
The QPair<T1, T1> should be Default Constructible and Copy Constructible to work with all methods of this class. Data types like QObject are not copy constructible and therefore should never be stored in a container. You can however use a pointer to a QObject or any subclass as the type T.
QPair< T1, T2 >::first_type |
The data type of the first element in the pair T1
.
QPair< T1, T2 >::second_type |
The data type of the second element in the pair T2
.
|
inline |
Constructs an empty QPair.
|
inline |
Constructs a pair and initializes the first element with value1 and the second element with value2.
|
default |
Copy constructs a new QPair from other.
|
default |
Move constructs a new QPair from other.
|
default |
Copy assigns from other and returns a reference to this object.
|
default |
Move assigns from other and returns a reference to this object.
void QPair< T1, T2 >::swap | ( | QPair< T1, T2 > & | other | ) |
Swaps this pair with other.
|
related |
Returns true if p1 is not equal to p2, otherwise returns false. Two pairs compare as not equal if their first data members are not equal or if their second data members are not equal.
This method requires the T1 and T2 types to have an implementation of operator==().
|
related |
Returns true if p1 is less than p2, otherwise returns false. The comparison is done on the first members of p1 and p2; if they compare equal, the second members are compared to break the tie.
This method requires the T1 and T2 types to have an implementation of operator<().
|
related |
Writes the given pair to the stream. Returns a reference to the stream. This method requires the T1 and T2 types to implement operator<<().
Refer to Serializing Data Types for additional information.
|
related |
Returns true if p1 is less than or equal to p2, otherwise returns false. The comparison is done on the first members of p1 and p2; if they compare equal, the second members are compared to break the tie.
This method requires the T1 and T2 types to have an implementation of operator<().
|
related |
Returns true if p1 is equal to p2, otherwise returns false. Two pairs compare equal if their first data members compare equal and if their second data members compare equal.
This method requires the T1 and T2 types to have an implementation of operator==().
|
related |
Returns true if p1 is greater than p2, otherwise returns false. The comparison is done on the first members of p1 and p2; if they compare equal, the second members are compared to break the tie.
This method requires the T1 and T2 types to have an implementation of operator<().
|
related |
Returns true if p1 is greater than or equal to p2, otherwise returns false. The comparison is done on the first
members of p1 and p2; if they compare equal, the second members are compared to break the tie.
This method requires the T1 and T2 types to have an implementation of operator<().
|
related |
Reads from the stream into the given pair. Returns a reference to the stream. This method requires the T1 and T2 types to implement operator>>().
Refer to Serializing Data Types for additional information.
|
related |
Constructs a new QPair which contains value1 and value2.
QPair< T1, T2 >::first |
The first element in a given pair.
QPair< T1, T2 >::second |
The second element in a given pair.