http://d.puremagic.com/issues/show_bug.cgi?id=4918

           Summary: tuples in eponymous template have default values only
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2010-09-23 01:10:49 
PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to