https://issues.dlang.org/show_bug.cgi?id=11466
--- Comment #5 from bearophile_h...@eml.cc --- (In reply to hsteoh from comment #4) > zip() will throw an exception if unequal-length ranges are passed to it. This is not true, this doesn't throw: void main() { import std.range: zip, StoppingPolicy; int[] a = [1]; int[] b = [1, 2]; foreach (pair; zip(a, b)) {} foreach (pair; zip(StoppingPolicy.shortest, a, b)) {} foreach (pair; zip(StoppingPolicy.longest, a, b)) {} } Only this one throws: void main() { import std.range: zip, StoppingPolicy; int[] a = [1]; int[] b = [1, 2]; foreach (pair; zip(StoppingPolicy.requireSameLength, a, b)) {} } > I don't know how to resolve this, The solution is to give StoppingPolicy as template argument to zip() instead of giving it as run-time value. This allows to specialize zip() at compile-time, allowing zip() with StoppingPolicy.shortest (that is the default) and with StoppingPolicy.longest to be nothrow. And leaving only the quite rarely used zip() with StoppingPolicy.requireSameLength not nothrow. For API compatibility you can even leave both ways to give StoppingPolicy to zip, or you can slowly deprecate the old way. --