Node:Pair,
Previous:Operators,
Up:Core components
Pair
|
The library includes templates for heterogeneous pairs of values.
|
| T1 first
|
Instance Variable of pair |
| T2 second
|
Instance Variable of pair |
| pair ()
|
Constructor on pair |
| pair (const T1& x, const T2& y)
|
Constructor on pair |
| ==
|
Operator on pair |
| <
|
Operator on pair |
template
struct pair {
T1 first;
T2 second;
pair() {}
pair(const T1& x, const T2& y) : first(x), second(y) {}
};
template
inline bool operator==(const pair& x, const pair& y) {
return x.first == y.first && x.second == y.second;
}
template
inline bool operator<(const pair& x, const pair& y) {
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
| pair<T1, T2> make_pair (
|
Function |
The library provides a matching template function
make_pair to simplify
their construction. Instead of saying, for example,
return pair(5, 3.1415926); // explicit types
one may say
return make_pair(5, 3.1415926); // types are deduced
|
template
inline pair make_pair(const T1& x, const T2& y) {
return pair(x, y);
}