In this case, {}
invokes value-initialization. If optional
‘s default constructor is not user-provided (where “not user-provided” means roughly “is implicitly declared or explicitly defaulted within the class definition”), that incurs zero-initialization of the entire object.
Whether it does so depends on the implementation details of that particular std::optional
implementation. It looks like libstdc++’s optional
‘s default constructor is not user-provided, but libc++’s is.