I am writing a C ++ parser (actually a small subset of it) and cannot find an explanation why the comma operator is not allowed when initializing variables.
int a = 1, 2;
a = 1, 2;
int a = (1, 2);
The C ++ specification says that you can use an expression as an initializer in a variable declaration. Why is the binary comma expression not allowed, but all other expressions (with higher priority) are allowed? cppreference.com ( http://en.cppreference.com/w/cpp/language/initialization ) says that any expression can be used as an initializer.
Section 8.5 of the C ++ specification states that an initializer can only contain an assignment expression. Is this the place that governs this assignment is the lowest priority allowed in initialization?
source
share