A tuple bug?

Max Samukha samukha at voliacable.com
Mon Apr 23 09:08:51 PDT 2007


The output when compiling the code below is "1, 1" while it should be
"1, 2".  When 'names' declarations are commented out, the output is
correct.

import std.stdio;

template Foo(A...)
{
    static if (A.length > 3)
    {
        const char[] names = A[0] ~ ", " ~ Foo!(A[3..$]).names;
        const char[] values = A[1].stringof ~ ", " ~
Foo!(A[3..$]).values;
    }
    else
    {
        static assert(A.length == 3);

        const char[] names = A[0];
        const char[] values = A[1].stringof;
    }
}

void main()
{
    pragma(msg, Foo!(
        "One", 1, "First item",
        "Two", 2, "Second item").values
    );
}

Is it a bug?


More information about the Digitalmars-d-learn mailing list