C++17 Init statement for if/switch

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 15 13:17:40 PDT 2017


On 08/15/2017 08:55 PM, 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);

Previous discussion:
http://forum.dlang.org/post/vfjlpvpwuyfqoljvpkkw@forum.dlang.org

Andrei doesn't like the C++ way, but he seems to be ok with the `with` way:
http://forum.dlang.org/post/oktru0$159b$1@digitalmars.com

Walter didn't comment.

I think this has a good chance of getting in, but someone will have to 
write a DIP and implement it.


More information about the Digitalmars-d mailing list