Function maybeSort
Might or might not sort a range, depending on some static properties of a range.
auto ref auto maybeSort(alias less, Range)
(
auto ref Range range
);
sort(range)
is calledsort!pred(range)
is calledSince
0.0.1
Example
import bolts .range: isSortedRange;
struct A { // unsortable
int i;
}
struct B { // sortable
int i;
bool opCmp(B a) const {
return i < a .i;
}
}
static assert( isSortedRange!([1] .maybeSort));
static assert(!isSortedRange!([A()] .maybeSort));
static assert( isSortedRange!([B()] .maybeSort));
static assert( isSortedRange!([A()] .maybeSort!"a.i < b.i"));