定义在头文件<utility>
成员变量:
- template<class _Ty1,class _Ty2>
- struct pair
- { // store a pair of values
- typedef pair<_Ty1, _Ty2> _Myt;
- typedef _Ty1 first_type;
- typedef _Ty2 second_type;
- _Ty1 first; // the first stored value
_Ty2 second; // the second stored value - }
构造函数:
1. 缺省
- pair(): first(_Ty1()), second(_Ty2())
- {
- // construct from defaults
- }
2.指定参数
- pair(const _Ty1& _Val1, const _Ty2& _Val2) : first(_Val1), second(_Val2)
- {
- // construct from specified values
- }
3.拷贝构造
- template<class _Other1,class _Other2>
- pair(const pair<_Other1, _Other2>& _Right) : first(_Right.first), second(_Right.second)
- {
- // construct from compatible pair
- }
make_pair
- template<class _Ty1,class _Ty2> inline
- pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2)
- {
- return (pair<_Ty1, _Ty2>(_Val1, _Val2));
- }