Why is std::nullopt_t part of the C++ standard?

前端 未结 2 691
一生所求
一生所求 2021-01-13 18:14

I don\'t understand the reasoning for the inclusion of std::nullopt_t in the standard. Does it exist strictly for convenience, or is it required in some niche c

2条回答
  •  一生所求
    2021-01-13 18:31

    C++ reference says it all:

    std::nullopt_t is an empty class type used to indicate optional type with uninitialized state. In particular, std::optional has a constructor with nullopt_t as a single argument, which creates an optional that does not contain a value.

    std::nullopt_t

提交回复
热议问题