Bug 5013 – std.typecons.Tuple should have constructor for static arrays
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-10-07T13:53:00Z
Last change time
2013-02-24T16:58:48Z
Assigned to
andrei
Creator
tomeksowi
Comments
Comment #0 by tomeksowi — 2010-10-07T13:53:09Z
Should work:
int[2] ints;
Tuple!(int, int) t = ints;
This leaves the reverse conversion unimplementable. A way out can be:
Tuple!(int, int) t;
auto ints = to!(int[2])(t);
Comment #1 by tomeksowi — 2010-10-07T13:58:25Z
(In reply to comment #0)
> This leaves the reverse conversion unimplementable. A way out can be:
>
> Tuple!(int, int) t;
> auto ints = to!(int[2])(t);
Or:
auto ints = cast(int[2]) t;
Seems more appropriate as no conversion takes place.
Comment #2 by jakobovrum — 2012-04-22T09:14:47Z
(In reply to comment #1)
> (In reply to comment #0)
>
> > This leaves the reverse conversion unimplementable. A way out can be:
> >
> > Tuple!(int, int) t;
> > auto ints = to!(int[2])(t);
>
> Or:
>
> auto ints = cast(int[2]) t;
>
> Seems more appropriate as no conversion takes place.
Structs can have padding, while static arrays cannot.
Comment #3 by github-bugzilla — 2013-02-24T16:58:48Z