www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2090] New: Cannot alias a tuple member which is a template instance

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2090

           Summary: Cannot alias a tuple member which is a template instance
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


----
template Tuple(A...)
{
    alias A Tuple;
}

template Bar()
{
    const s = "a bar";
}

alias Tuple!(Bar!()) tuple;
const i = 0;
alias tuple[i] bar; // 'alias tuple[0] bar;' works 

static assert(bar.s == "a bar");
----
Error: tuple[0] is not a type


-- 
May 09 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2090





------- Comment #1 from samukha voliacable.com  2008-05-10 03:01 -------
It may be not a blocker as a workaround exists:
----
template Tuple(A...)
{
    alias A Tuple;
}

template Bar()
{
    const s = "a bar";
}

char[] toString(size_t v)
{    
    char[] s;
    s ~= "                    ";
    size_t i = 1;

    do
    {
        s[s.length - i] = '0' + v % 10;
        i++;
        v /= 10;
    } while (v)

    return s[$ - i + 1..$];
}

alias Tuple!(void, Bar!()) tuple;
const i = 1;
mixin ("alias tuple[" ~ toString(i) ~ "] bar;");

static assert(bar.s == "a bar");

void main()
{
}
----


-- 
May 10 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2090


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2008-05-22 05:06 -------
Fixed dmd 1.030 and 2.014


-- 
May 22 2008