std.range.indexed of DMD 2.055 is very nice. But it signature shows constraints 
that I have had problems to work with, maybe the error is just mine, I don't 
know:


import std.algorithm, std.range, std.array;
void main() {
    auto data = [7, 6, 5, 4, 3, 2, 1, 0];
    auto indices = [6, 1, 7];

    //auto idxSet = array(uniq(indices.sort())); // OK
    auto idxSet = uniq(indices.sort()); // not OK?

    // std.range.indexed() constraints
    static assert(isInputRange!(typeof(idxSet))); // OK
    static assert( is(typeof((int[]).init[ElementType!(typeof(idxSet)).init])) 
); // OK

    sort(indexed(data, idxSet));
    assert(data == [7, 0, 5, 4, 3, 2, 1, 6]);
}


Bye and thank you,
bearophile

Reply via email to