isNeighbourhood

Tests if something is a Neighbourhood. * returns true if T is a Neighbourhood of dimension N. * A Neighbourhood is the most basic form of a $(NEIGHBOURHOOD). It's getNeighboursCoordinates function takes a cells position and returns a list of coordinate pairs for it's neighbours positions. * It must define the primitive:
int[N][] getNeighboursCoordinates(Coord).
Where N is the dimension of the Neighbourhood and Coord is an alias for a typetuple containing int's, one int for each dimension (in a 3 dimensional Neighbourhood Coord would be: (int, int, int)). *

template isNeighbourhood (
T
uint N
) {
enum isNeighbourhood;
enum isNeighbourhood;
}

Parameters

T

type to be tested

N

number of dimensions *

Return Value

true if T is a Neighbourhood, false if not

Examples

1 struct A {
2 	enum uint Dimension = 2;
3 	int[2][] getNeighboursCoordinates(int x, int y) {
4 		return [[x+1, y+1], [x+1, y], [x+1, y-1]];
5 	}
6 }
7 
8 static assert( isNeighbourhood!(A, 2));
9 static assert(!isNeighbourhood!(string, 1));

Meta