This doesn't compile because T is const(int) so you can't modify the arguments a and b, despite they are values:

void foo(T)(T a, T b) {
    a = b;
    b = a;
}
void main() {
    const int x, y;
    foo(x, y);
}


To make that code work I'd like to write something like this:

void foo(T)(Deconst!T a, Deconst!T b) {

Or this:

void foo(T)(@deconst T a, @deconst T b) {

Bye,
bearophile

Reply via email to