# deduction guides for `std::optional`

From cppreference.com
< cpp‎ | utility‎ | optional

Defined in header `<optional>` |  |
template<class T> optional(T) -> optional<T>; |  | (since C++17)

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

### Example

Run this code

    #include <optional>

    int main()
    {
        int a[2];
        std::optional oa{a}; // explicit deduction guide is used in this case
    }

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/optional/deduction_guides&oldid=94036"