Tuple expansion already?
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Tue Nov 17 19:30:50 PST 2015
On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
> For once, let's take something from C++. ;) Structured bindings
> are accepted for C++:
>
> https://isocpp.org/blog/2015
>
> Assuming that f() returns a tuple,
>
> auto {x,y,z} = f();
>
> will be the same as
>
> auto t = f();
> auto x = get<1>(t);
> auto y = get<2>(t);
> auto z = get<3>(t);
>
> Ali
100x yes. Also dedicated tuple syntax and multiple return types
like
#(int, string) getTup()
{
return #(0, "");
}
#(i, s) = getTyp();
writeln("i = ", i, ", s = ", s);
More information about the Digitalmars-d
mailing list