Checking function parameters in Phobos
Timon Gehr
timon.gehr at gmx.ch
Wed Nov 20 04:56:35 PST 2013
On 11/20/2013 08:49 AM, Jacob Carlborg wrote:
> Would we accompany the assumeSorted with an assert in the function
> assuming something is sorted? We probably don't want to rely on convention.
We do in any case:
import std.algorithm, std.range;
void main(){
auto a = [1,2,3,4,5];
auto s = sort(a);
swap(a[0],a[$-1]);
assert(is(typeof(s)==SortedRange!(int[])) && !s.isSorted());
}
More information about the Digitalmars-d
mailing list