Reputation: 3829
const int number{42};
Is this valid syntax? I can only find examples where the curly-brace initializers are used for objects or non-trivial types.
Upvotes: 2
Views: 348
Reputation: 172448
The simple answer to your question is YES it is allowed and it is a valid syntax.
You may check Uniform initialization syntax and semantics by stroustrup
Also to add that as per C++98 8.5/13:
If
T
is a scalar type, then a declaration of the form
T x = { a };
is equivalent to
T x = a;
Upvotes: 9