I am trying to understand the exact behavior of value initialization by T() or T{} for a class type T in C++11. What confuses me are these two snippets taken from http://en.cppreference.com:
The effects of value initialization are: [...]
1) if T is a class type with no default constructor or with a user-provided or deleted default constructor, the object is default-initialized; (since C++11)
[...]
so I looked up Default-Initialization:
The effects of default initialization are:
- if T is a [...] class type, the constructors are considered and subjected to overload resolution against the empty argument list. The constructor selected (which is one of the default constructors) is called to provide the initial value for the new object;
[...]
So this basically says that if T is a class type and its implicit default constructor is not available, then the object will be constructed by a call to one of its default constructors? In my understanding, this makes only sense for the mentioned case of a user-provided default constructor; then, upon construction, only what is explicitly stated in that constructor will be executed, and every member not explicitly initialized will get default-initialized (please correct me if I am wrong here).
My questions:
1) What would happen if there was no user-provided default constructor and there was no default constructor or it was deleted? I would guess the code would not compile. If this is right, then:
2) What is the need to also explicitly mention the cases "no default constructor" and "deleted default constructor"?