An example. Note that, unlike the similar Visitor test case, this iterates only once, thanks to the opBinary support.
// Setup enum VarName : uint { x, y, z, tempVarStart = 100, tempVarEnd = 200 } MapSetVars!(VarName, int) v; alias M = MapSetVars!(VarName, int).Set; M m = v.Set.unitSet; m = m.cartesianProduct(VarName.x, [1, 2, 3]); m = m.cartesianProduct(VarName.y, [10, 20, 30]); v.visitor = v.Visitor(m); // The algorithm that runs on the mapset void theAlgorithm() { v.var.z = v.var.x + v.var.y; } // The evaluation loop M results; size_t numIterations; while (v.next()) { theAlgorithm(); results = results.merge(v.visitor.currentSubset); numIterations++; } assert(numIterations == 1); assert(results.all(VarName.z) == [11, 12, 13, 21, 22, 23, 31, 32, 33]);
A wrapper around a MapSetVisitor which allows interacting with it using a more conventional interface.