C++ Logo


Advanced search

Subject: Re: [std-proposals] dofor loop
From: Matthew Woehlke (mwoehlke.floss_at_[hidden])
Date: 2019-12-30 14:57:26

On 27/12/2019 14.44, John Yates via Std-Proposals wrote:
> If `do` were to get an optional init-statement and `while` an optional
> increment-statement then you could have:
> do [ (init-statement) ]
> {
> ...statements...
> } while (condition [ ; increment-statement ] )

I wouldn't mind `while (cond; incr)` either, especially if it extends to
non-do loops (yes, even though that's just `for (; cond; incr)`, because
IMHO that's ugly and I tend to try to avoid it as a result).

Actually, I just realized, if we *could* get this, it would help with
another long-standing request... namely:

  do (auto something = decl)
  } while (false)

...which is still a little ugly, but less so IMHO than a bare block. If
nothing else, it would (slightly) simplify the body of my `#define


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups