← Back to index
|
Original Bugzilla link
Bug 4918 – tuples in eponymous template have default values only
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-09-23T01:10:00Z
Last change time
2015-06-09T05:14:37Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0
by issues.dlang — 2010-09-23T01:10:49Z
This code import std.stdio; import std.typecons; template mytemp(T...) { static if(T.length == 1) enum mytemp = tuple(T[0]); else enum mytemp = tuple(T[0], mytemp!(T[1..$]).expand); } void main() { writeln(mytemp!(5)); writeln(mytemp!(5, 10, 7)); writeln(mytemp!(true)); writeln(mytemp!(true, false, true)); writeln(mytemp!("hello")); writeln(mytemp!("hello", "world")); } results in this output Tuple!(int)(0) Tuple!(int,int,int)(0, 0, 0) Tuple!(bool)(false) Tuple!(bool,bool,bool)(false, false, false) Tuple!(string)() Tuple!(string,string)(, ) If I change it to import std.stdio; import std.typecons; template mytemp(T...) { enum mytemp = T[0]; } void main() { writeln(mytemp!(5)); writeln(mytemp!(true)); writeln(mytemp!("hello")); } I get 5 true hello So obviously, there's something wrong with tuple here. And it's pretty crippling for my current project actually.
Comment #1
by yebblies — 2012-02-14T08:18:56Z
Seem to work with dmd 2.058