名稱空間
變體
操作

std::pair 的推導指南

來自 cppreference.com
< cpp‎ | 工具‎ | 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
}