std::pair
STD:一对
Defined in header | | |
---|
template< class T1, class T2 > struct pair; | | |
std::pair
是一个struct模板,它提供了将两个异构对象作为一个单元存储的方法。对是std::tuple
有两个元素。
If std::is_trivially_destructible_v && std::is_trivially_destructible_v is true, the destructor of pair is trivial. | (since C++17) |
---|
模板参数
T1, T2 | - | the types of the elements that the pair stores. |
---|
成员类型
Member type | Definition |
---|
first_type | T1 |
second_type | T2 |
成员对象
Member name | Type |
---|
first | T1 |
second | T2 |
成员函数
(constructor) | constructs new pair (public member function) |
---|
operator= | assigns the contents (public member function) |
swap (C++11) | swaps the contents (public member function) |
非会员职能
make_pair | creates a pair object of type, defined by the argument types (function template) |
---|
operator==operator!=operator<operator<=operator>operator>= | lexicographically compares the values in the pair (function template) |
std::swap(std::pair) (C++11) | specializes the std::swap algorithm (function template) |
std::get(std::pair) (C++11) | accesses an element of a pair (function template) |
帮助者类
std::tuple_size (C++11) | obtains the size of a pair (class template specialization) |
---|
std::tuple_element<std::pair> (C++11) | obtains the type of the elements of pair (class template specialization) |
另见
tuple (C++11) | implements fixed size container, which holds elements of possibly different types (class template) |
---|
tie | creates a tuple of lvalue references or unpacks a tuple into individual objects (function template) |
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
http://en.cppreference.com/w/cpp/实用程序/对