Do you know how to perform the xor trick
(http://en.wikipedia.org/wiki/XOR_swap_algorithm ) on two
pointers in D?
This is a try:
void foo(T)(ref T x, ref T y) pure nothrow {
x ^= y;
y ^= x;
x ^= y;
}
void main() {
int* p, q;
foo(p, q);
}
Currently that gives:
test.d(2): Error: 'x' is not of integral type, it is a int*
test.d(2): Error: 'y' is not of integral type, it is a int*
test.d(3): Error: 'y' is not of integral type, it is a int*
test.d(3): Error: 'x' is not of integral type, it is a int*
test.d(4): Error: 'x' is not of integral type, it is a int*
test.d(4): Error: 'y' is not of integral type, it is a int*
test.d(8): Error: template instance test.foo!(int*) error
instantiating
Bye,
bearophile