Structured binding declaration (like in C++)

MoonlightSentinel moonlightsentinel at disroot.org
Thu Oct 14 15:29:13 UTC 2021


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


More information about the Digitalmars-d-learn mailing list