This describes nullopt_t and nullopt for the optional object proposed for C ++:
struct nullopt_t{see below}; constexpr nullopt_t nullopt(unspecified);
[...] The nullopt_t type should not have a default constructor. It must be a literal type. The nullopt constant is initialized with an argument of the literal type.
The reason for this is explained in the op = {} chapter of the document syntax : for op = {} be unambiguous, some tricks must be accepted, one of which is that nullopt_t does not have to be constructive by default.
My question is, what does the literal type mean here? I found this SO post . So it seems to me that this will make another empty class. Could it be a constructor with int ?
What does the minimally matching nullopt_t class nullopt_t ?
Something like that:
struct nullopt_t_construct_tag_t{}; struct nullopt_t { nullopt_t() = delete;
Or that:
struct nullopt_t { nullopt_t() = delete; constexpr nullopt_t(int) {}; }; constexpr nullopt_t nullopt(0);
bolov source share