Refined types [almost OT]

Meta via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 12 12:21:25 PDT 2014


On Sunday, 12 October 2014 at 16:21:50 UTC, bearophile wrote:
What happens if one of these conditions fails? Is an exception 
thrown? Note that you can also sort of do this using template 
constraints, but that of course only works at compile time:

double get2dimensional(int n, int m, int i, int j, double[] arr)()
if (n >= 0
     && m >= 0
     && 0 <= i
     && i < m
     && 0 <= j
     && j < n
     && arr.length == m * n)
{
     return arr[i * n + j];
}


More information about the Digitalmars-d mailing list