Regarding std.range.indexed
bearophile
bearophileHUGS at lycos.com
Mon Jan 13 17:14:40 PST 2014
Code like this doesn't compile, the swap doesn't work:
import std.range: indexed;
import std.algorithm: swap;
void main() {
immutable source = [10, 20, 30];
auto ind = indexed(source, [0, 1, 2]);
swap(ind[0], ind[1]);
}
But isn't an important usage case of indexed() to shuffle and
sort a view of an immutable array, like sorting a
immutable(int)*[] ?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list