Structured binding declaration (like in C++)

Vindex tech.vindex at gmail.com
Thu Oct 14 18:01:49 UTC 2021


On Thursday, 14 October 2021 at 15:29:13 UTC, MoonlightSentinel 
wrote:
> On Wednesday, 13 October 2021 at 20:02:05 UTC, Vindex wrote:
>> Is there a decomposition for tuples and other data structures?
>
> No, but you can emulate it, e.g. by using AliasSeq:
>
> ```d
> import std.meta : AliasSeq;
> import std.typecons : tuple;
> import std.stdio : writeln;
>
> void main() {
>     int a;
>     string b;
>     AliasSeq!(a, b) = tuple(1, "hello");
>
>     writeln("a = ", a);
>     writeln("b = ", b);
> }
> ```
>
> https://run.dlang.io/is/aUEtSK

Thank you! This is a good variant of decision of the problem


More information about the Digitalmars-d-learn mailing list