deductiongu...rstd::tuple(3)
π NAME π
okay so bestie, this page is deductiongu...rstd::tuple(3) from the C++ Standard Libary section (yes, thatβs literally how the header spells it, weβre keeping it π
). The actual name situation is deductionguidesforstd::tuple β and itβs exactly what it sounds like: deduction guides for std::tuple β¨.
πΈ Synopsis πΈ
Defined in header <tuple>. Every single one of these is since C++17, no cap π«Ά.
(1) β since C++17
template<class... UTypes>
tuple(UTypes...) -> tuple<UTypes...>;
(2) β since C++17
template<class T1, class T2>
tuple(std::pair<T1, T2>) -> tuple<T1, T2>;
(3) β since C++17
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, UTypes...) -> tuple<UTypes...>;
(4) β since C++17
template<class Alloc, class T1, class T2>
tuple(std::allocator_arg_t, Alloc, std::pair<T1, T2>) -> tuple<T1, T2>;
(5) β since C++17
template<class Alloc, class... UTypes>
tuple(std::allocator_arg_t, Alloc, tuple<UTypes...>) -> tuple<UTypes...>;
These deduction guides are here for std::tuple to cover the edge cases that the implicit deduction guides miss β especially non-copyable arguments and array to pointer conversion ππ₯.
π§ͺ 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
}
like, this example is literally the moment: int a[2], b[3], c[4]; and then std::tuple t1{a, b, c}; β and the explicit deduction guide is used in this case π. iconic behavior, honestly.
mwah π sign-off time: source is http://cppreference.com, version/date is 2024.06.10, and the footer manual name is deductiongu...rstd::tuple(3) β periodt ππ¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms