www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4918] New: tuples in eponymous template have default values only

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



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: -------
Sep 23 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4918


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         Resolution|                            |WORKSFORME
         OS/Version|Linux                       |All



Seem to work with dmd 2.058

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