Any way to expand a tuple?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Sep 24 15:23:18 PDT 2011


import std.typetuple;
import std.typecons;

struct Foo
{
    void test(int x, double y) { }

    void opOpAssign(string op, T...)(T t)
        if (op == "~")
    {
        test(t);
    }
}

void main()
{
    Foo foo;
    foo.opOpAssign!"~"(4, 5.0);  // ok
    foo ~= tuple(4, 5.0);  // fail
}

If I understand this correctly in the first call T becomes a D
language tuple, while in the second one it's a phobos library tuple. I
really hate this distinction and would love these two to be merged so
the second call could compile.

Is it possible to expand the phobos tuple in the call to test()? I can
use the isTuple template in a `static if` to figure out if it needs
expansion, so all that's left is to actually expand the phobos tuple.


More information about the Digitalmars-d-learn mailing list