首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::pair

Defined in header <utility>

template< class T1, class T2 > struct pair;

std::pair是一个struct模板,它提供了将两个异构对象作为一个单元存储的方法。对是std::tuple有两个元素。

If std::is_trivially_destructible_v<T1> && std::is_trivially_destructible_v<T2> 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<std::pair> (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)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券