deduction guides for std::tuple
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
Common vocabulary types
std::tuple
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
(C++23)
(C++23)
(C++23)
Deduction guides(C++17)
Defined in header
<tuple>
template<class... UTypes>
tuple(UTypes...) -> tuple<UTypes...>;
(1)
(since C++17)
tuple(UTypes...) -> tuple<UTypes...>;
template<class T1, class T2>
tuple(std::pair <T1, T2>) -> tuple<T1, T2>;
(2)
(since C++17)
tuple(std::pair <T1, T2>) -> tuple<T1, T2>;
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>;
(3)
(since C++17)
tuple(std::allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>;
template<class Alloc, class T1, class T2>
tuple(std::allocator_arg_t, Alloc, std::pair <T1, T2>) -> tuple<T1, T2>;
(4)
(since C++17)
tuple(std::allocator_arg_t, Alloc, std::pair <T1, T2>) -> tuple<T1, T2>;
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;
(5)
(since C++17)
tuple(std::allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;
These deduction guides are provided for std::tuple to account for the edge cases missed by the implicit deduction guides, in particular, non-copyable arguments and array to pointer conversion.
[edit] Example
Run this code
#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 }