while (T t = x) statement
label: { // start of condition scope T t = x; if (t) { statement goto label; } } // end of condition scopeThe variable created in a condition is destroyed and created with each iteration of the loop.
struct A {
int val;
A(int i) : val(i) { }
~A() { }
operator bool() { return val != 0; }
};
int i = 1;
while (A a = i) {
// ...
i = 0;
}