名前空間
変種
操作

std::tuple の推論補助

From cppreference.com
< cpp‎ | utility‎ | tuple
 
 
ユーティリティライブラリ
言語サポート
型のサポート (基本型、RTTI)
ライブラリ機能検査マクロ (C++20)
プログラムユーティリティ
可変引数関数
コルーチンサポート (C++20)
契約サポート (C++26)
三方比較
(C++20)
(C++20)(C++20)(C++20)  
(C++20)(C++20)(C++20)

汎用ユーティリティ
関係演算子 (C++20で非推奨)
 
 
ヘッダ <tuple> で定義
template<class... UTypes>
tuple(UTypes...) -> tuple<UTypes...>;
(1) (C++17以降)
template<class T1, class T2>
tuple(std::pair<T1, T2>) -> tuple<T1, T2>;
(2) (C++17以降)
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>;
(3) (C++17以降)
template<class Alloc, class T1, class T2>
tuple(std::allocator_arg_t, Alloc, std::pair<T1, T2>) -> tuple<T1, T2>;
(4) (C++17以降)
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;
(5) (C++17以降)

これらの推論補助は、std::tuple のために提供されており、暗黙の推論補助では見逃されるエッジケース、特にコピー不能な引数や配列からポインタへの変換を考慮しています。

[編集]

#include <tuple>
int main()
{
    int a[2], b[3], c[4];
    std::tuple t1{a, b, c}; // explicit deduction guide is used in this case
}
English 日本語 中文(简体) 中文(繁體)