Date: Tue, 29 Apr 2025 19:43:43 +0900
There is a fairly arbitrary (unless I missed an important argument)
limitation on initialization clause for if statements.
- I have that
if (auto it = vec.begin(); it != vec.end()) {
- I want this
if (auto it = vec.begin() /*and*/ auto itt = ++vec.begin(); it !=
vec.end() && it != itt) {
So you end up using one of the workarounds, which are somewhat hacky imo :/
I'd like to release that restriction and have for example
if ({
auto it = vec.begin();
auto itt = ++vec.begin();
}; it != vec.end() && it != itt) {
which can be desugared (desugarified ?) to e.g.
{
auto it = vec.begin();
auto itt = vec.begin();
if (it != vec.end()) {
}
}
Colleague pointed me to a GCC expression statements extension which ?maybe?
makes `if ({` ambiguous to parse, so I would have to look into that too…
Is there any current proposal that aims to lift that restriction ?
Cheers.
Sent from Gmail Mobile
limitation on initialization clause for if statements.
- I have that
if (auto it = vec.begin(); it != vec.end()) {
- I want this
if (auto it = vec.begin() /*and*/ auto itt = ++vec.begin(); it !=
vec.end() && it != itt) {
So you end up using one of the workarounds, which are somewhat hacky imo :/
I'd like to release that restriction and have for example
if ({
auto it = vec.begin();
auto itt = ++vec.begin();
}; it != vec.end() && it != itt) {
which can be desugared (desugarified ?) to e.g.
{
auto it = vec.begin();
auto itt = vec.begin();
if (it != vec.end()) {
}
}
Colleague pointed me to a GCC expression statements extension which ?maybe?
makes `if ({` ambiguous to parse, so I would have to look into that too…
Is there any current proposal that aims to lift that restriction ?
Cheers.
Sent from Gmail Mobile
Received on 2025-04-29 10:43:56