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
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/702daca3123caaba3c734d3d5e265c131734ecc4 issue 5013 https://github.com/D-Programming-Language/phobos/commit/35d08ef3d8e1148f2e34b3831cff8eeb649461b3 Merge pull request #1153 from andralex/5013 Fix Issue 5013 - std.typecons.Tuple should have constructor for static arrays