tuple の推論ガイドstd::tuple
ja.cppreference.net より
| ヘッダ <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}; // この場合、明示的なデダクションガイドが使用されます }