
From: "Jeremy Maitin-Shepard" <jeremy@jeremyms.com> The fact that built-in types in C++ have a special "uninitialized" state separate from the default constructed state necessary makes them a special case. Nonetheless, a default constructor is often useful even if it serves to create an arbitrary initial state with only the guarantee that it won't leak memory, etc.
In my nick of the woods that is not a sufficient guarantee. That requires *all* the code dealing with the relevant object to have checks if that object indeed has been constructed properly and has value or it just "won't leak memory". That is a case similar to pointers vs. references debate.
Basically it allows the type to serve as its own optional<>, with the caveat that you cannot check if it has been initialized and don't need to dereference it explicitly.
When I need optional<>, I'll use optional<>.
This often is more convenient/leads to better syntax that having to use optional<> or a smart pointer of some type everywhere.
I disagree. In my view it leads to avoidable and error-prone code where I forget to check if the passed-in object has, in-fact, a valid state and proceed using it.
For instance, arrays (and some other containers) require a default constructor.
I knew containers will come up as an example sooner and later. An empty container is a valid object in a useble state. There is nothing optional about it. V.