Ddoc documentation:
http://peylow.noip.org/~peylow/set.html
Actual implementation:
http://peylow.noip.org/~peylow/set.d
I whipped up a module with templates for Ranges and Sets. Ranges are only useful for numerical values. Sets can be used for any value; a set of {1, 2, 3} is just as valid as a set of {green, whale, 42}.
Currently only empty and finite ranges are supported (Infinite set if you make a range over real numbers), infinite and non continuous ranges would be nice, but that is a task for another day. Unions, intersection, complements, membership test and iterations can naturally be done on sets. As well as construction a set from a range non continuous range.
Empty, finite, and infinite sets are supported. Unions, intersections, unary and binary complements, membership tests, and iterations over set members supported.
Three classes are used in combination to allow for full naive set algebra;
Set  For finite sets.
FunctionSet  An infinite set with members defined by function.
CombiningSet  An infinite set construction by combining sets.
The optimal set class is constructed for each operation (union, intersection, etc). Maybe CombinedSet should be named ComputedSet?
Three global sets provided;
evenIntSet  A set of all even integers.
oddIntSet  A set of all odd integers.
primeIntSet  A set of all primes.
Comments, and bug hunt requested :)
// Fredrik
