I can create a mutable array of immutable objects, thanks to the
answers to my other question
https://forum.dlang.org/post/[email protected] .
Now I want to sort the array, but the sort function doesn't "see"
the opCmp in class C. Do I need to define a custom compare
function for each class where I want to use Rebindable? Or can
Rebindable itself be updated to "pass through" methods like opCmp?
class C {
this(int x) immutable { this.x = x; }
override int opCmp(Object o) const { return x - (cast(C)o).x; }
int x;
}
void main(string[] args)
{
auto array = new Rebindable!(immutable(C))[2];
array[0] = new immutable C(20);
array[1] = new immutable C(10);
sort(array); // Error: "Invalid predicate passed to sort: "a <
b""
}