deductiongu...td::optional(3)
π deductionguidesforstd::optional π
okay so bestie, welcome to the C++ Standard Libary page for deductiongu...td::optional(3) β the header is giving cryptic, so weβre just folding the manual name in right here and keeping it cute. π«Άβ¨
π NAME π
deductionguidesforstd::optionalβdeductionguidesforstd::optional
β¨ Synopsis β¨
Defined in header <optional> π¦
template< class T > (since C++17)
optional(T) -> optional<T>;
One deduction guide is provided for std::optional to account for the edge cases missed by the implicit deduction guides, in particular, non-copyable arguments and array to pointer conversion. Thatβs literally the assignment, no cap. π
πΈ Example πΈ
// Run this code
#include <optional>
#include <type_traits>
int main()
{
int a[2];
std::optional oa{a}; // uses explicit deduction guide
static_assert(std::is_same_v<decltype(oa), std::optional<int*>> ==
true);
}
source/version + date sign-off, bestie: http://cppreference.com Β· 2024.06.10 Β· deductiongu...td::optional(3) β slay and goodbye ππ
π¦ 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