const int[0] x;
size_t index;
import std.range : assumeSorted;
assert(!x[].assumeSorted.containsStoreIndex(int.min, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(-1, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(0, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(1, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(int.max, index) && index == 0);
const int[2] x = [1, 3];
size_t index;
import std.range : assumeSorted;
assert(!x[].assumeSorted.containsStoreIndex(int.min, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(-1, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(0, index) && index == 0);
assert( x[].assumeSorted.containsStoreIndex(1, index) && index == 0);
assert(!x[].assumeSorted.containsStoreIndex(2, index) && index == 1);
assert( x[].assumeSorted.containsStoreIndex(3, index) && index == 1);
assert(!x[].assumeSorted.containsStoreIndex(4, index) && index == 2);
assert(!x[].assumeSorted.containsStoreIndex(5, index) && index == 2);
assert(!x[].assumeSorted.containsStoreIndex(int.max, index) && index == 2);
Same as range.contains() but also outputs index where last occurrence of key is either currently stored (if true is returned) or should be stored (if false is returned) in order to preserve sortedness of range.
The elements of range are assumed to be sorted in default (ascending) order.
TODO Move to member of SortedRange either as a new name or as an contains-overload take an extra index as argument.