On Tuesday, 15 August 2017 at 18:55:57 UTC, Daniel Kozak wrote:
C++17 will have this feature:
https://tech.io/playgrounds/2205/7-features-of-c17-that-will-simplify-your-code/init-statement-for-ifswitch
What do you think about it, can we have something similar to
that.
Maybe something like this:
int func() return 5;
with(auto x = func()) if (condition(x))
do_something_with(x);
else
do_something_else_with(x);
this would be rewrite to
int func() return 5;
{
auto x = func();
if (condition(x))
do_something_with(x);
else
do_something_else_with(x);
}