[Issue 1839] Give D a modern varargs system that allows forwarding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 15 01:35:25 PST 2008


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





------- Comment #8 from andrei at metalanguage.com  2008-02-15 03:35 -------
I misunderstood your initial code sample. In fact that's a simpler problem:

import std.stdio;

void before() {}
void after() {}

void fn(...)
{
    foreach (i; 0 .. _arguments.length)
    {
        _arguments[i].print;
    }
    if (_arguments[0] == typeid(int))
    {
        int j = *cast(int *)_argptr;
        writeln(j);
    }
}

void wrapsFn(T...)(T args)
{
    before();
    scope(exit) after();
    fn(args);
}

void main()
{
    wrapsFn(2, 42, "a");
}


-- 



More information about the Digitalmars-d-bugs mailing list