[Issue 5127] Template instantiation arguments with integer operations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 28 16:35:14 PDT 2010


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



--- Comment #1 from bearophile_hugs at eml.cc 2010-10-28 16:34:23 PDT ---
Currently the best workaround for that limitation is to use a template
constraint:


void doubleit(T, int n, int m)(T[n] data, out T[m] result) if (m == n+n) {
    foreach (i, x; data) {
        result[i * 2] = x;
        result[i * 2 + 1] = x;
    }
}
void main() {
    int[4] v = [1, 2, 3, 4];
    int[8] r;
    doubleit(v, r);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list