Basically, why is this valid:
auto p1 = new int[10]{5};
but this is not:
auto p1 = new int[10](5);
And more generally what are the rules for the new-expression initializer?
I found the following:
— If the new-initializer is omitted, the object is default-initialized (8.5). [ Note: If no initialization is performed, the object has an indeterminate value. — end note ] — Otherwise, the new-initializer is interpreted according to the initialization rules of 8.5 for direct- initialization.
So is the second case invalid because smth like T((5))
is invalid (direct initialization from expression (5)
)? Or what is the reason?
EDIT: well, my suggestion of (())
thing seems dumb because I see no reason why that should only apply to array new-expression.