Previous : Operators, Top : Table of Contents
| pair
|
Class |
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 |
templatestruct 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 pairone may say:(5, 3.1415926); // explicit types
return make_pair(5, 3.1415926); // types are deduced
templateinline pair make_pair(const T1& x, const T2& y) { return pair (x, y); }
|
|
|