Bug 4536 – Typetuples (T...) should have an .init member

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-30T03:05:00Z
Last change time
2012-02-18T23:00:43Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
philippe.sigaud

Comments

Comment #0 by philippe.sigaud — 2010-07-30T03:05:32Z
Typetuples (T...) should have an .init member. Them not having it is a bother for generic code. Say I have a template that takes an alias and a T..., and I want to verify that the alias is a function accepting T...: template Test(alias fun ,T...) if (is(typeof(fun(T.init))) {...} This does not work, which I find frustrating. I have to use this workaround: template Init(T...) { alias (Tuple!T.init).expand Init; } That is, using std.typecons.Tuple as an initiator.
Comment #1 by philippe.sigaud — 2010-08-19T13:35:10Z
(In reply to comment #0) > template Init(T...) > { > alias (Tuple!T.init).expand Init; > } Hmm, my mistake, the previous version doesn't work. I'm pretty sure it used to, since I was using it in my code. Anyway, here is a far more simple version, no dependency: template Init(T...) { T Init; } a initialized T is correctly created. I still think .init should work like this for typetuples.
Comment #2 by yebblies — 2011-06-15T08:10:41Z
What should .init do for a TypeTuple like this? TypeTuple!(3, int).init = ?
Comment #3 by bearophile_hugs — 2011-06-15T09:48:06Z
(In reply to comment #2) > What should .init do for a TypeTuple like this? > TypeTuple!(3, int).init = ? I think raise a syntax error (or return a TypeTuple!(3, 0)).
Comment #4 by yebblies — 2012-02-14T20:24:34Z
Comment #5 by github-bugzilla — 2012-02-18T20:36:14Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/809ce857f166a48a05560da95a11fb75fcbb2c1d Merge pull request #719 from yebblies/issue4536 Issue 4536 - Typetuples (T...) should have an .init member