identic ref/inout parameter
Jarrett Billingsley
kb3ctd2 at yahoo.com
Fri Sep 14 12:25:49 PDT 2007
"Downs" <default_357-line at yahoo.de> wrote in message
news:fce15c$1h7e$1 at digitalmars.com...
> To clean it up a little
>
> void assertUnique(T)(ref T[] values...) {
> foreach (index, ref value; values[0..$-1])
> foreach (ref value2; values[index+1..$])
> assert(&value != &value2);
> }
Probably not _quite_ what you'd expect. "ref T[]" means "ref(T[])", not
"(ref T)[]". That is, a reference to an array, not an array of references.
So it'd have to be "T*[] values..." instead, and called as
"assertUnique(&r1, &r2, &i1, &i2)".
More information about the Digitalmars-d-learn
mailing list