identic ref/inout parameter

Wilhelm Wilhelm.Kopenpart at t-online.de
Fri Sep 14 03:45:31 PDT 2007


Who do I determine in a function (probably with a assert statement) that the function with more the one ref/inout parameters of the same type are not called with the same variable like:

private import std.stdio;

int main(char[][] args)
{
    int i=3;
    test( i,i,i,i);
    return 0;
}


void test(ref int r1, ref int r2, inout int i1, inout int i2)
{
	writefln ("           Ref: r1=%d r2=%d", r1, r2);
	writefln ("         InOut: i1=%d i2=%d", i1, i2);
	r1 += 2;
	writefln ("r1 += 2;   Ref: r1=%d r2=%d", r1, r2);
	writefln ("r1 += 2; InOut: i1=%d i2=%d", i1, i2);
	i2 += 2;
	writefln ("i1 += 2;   Ref: r1=%d r2=%d", r1, r2);
	writefln ("i1 += 2; InOut: i1=%d i2=%d", i1, i2);
}

!! That may cause interesting results !!




More information about the Digitalmars-d-learn mailing list