On Wednesday, 21 August 2013 at 02:46:06 UTC, Dylan Knutson wrote:
[..]
----------------------------------------------------------------------
T foo(T)(ref T thing)
{
        thing++; return thing * 2;
}

foreach(Type; TupleType!(int, long, uint))
{
        unittest
        {
                Type tmp = 5;
                assert(foo(tmp) == 12);
        }
        
        unittest
        {
                Type tmp = 0;
                foo(tmp);
                assert(tmp == 1);
        }
}
----------------------------------------------------------------------
[..]

Why not just do this:

import std.typetuple;

T foo(T)(ref T thing)
{
    thing++; return thing * 2;
}

unittest
{
    foreach(Type; TypeTuple!(int, long, uint))
    {
        {
            Type tmp = 5;
            assert(foo(tmp) == 12);
        }

        {
            Type tmp = 0;
            foo(tmp);
            assert(tmp == 1);
        }
    }
}

Reply via email to