命名空间
变体
操作

std::pair 的推导指引

来自 cppreference.cn
< cpp‎ | utility‎ | pair
 
 
 
 
定义于头文件 <utility>
template<class T1, class T2>
pair(T1, T2) -> pair<T1, T2>;
(自 C++17 起)

std::pair 提供了一个推导指引,以解决隐式推导指引遗漏的边缘情况,特别是不可复制的参数和数组到指针的转换。

[编辑] 示例

#include <utility>
 
int main()
{
    int a[2], b[3];
    std::pair p{a, b}; // explicit deduction guide is used in this case
}