Bug 18638 – The main override of std.range.zip could infer @nogc and nothrow

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-20T14:09:40Z
Last change time
2018-03-30T01:38:53Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-03-20T14:09:40Z
The override of `std.range.zip` that doesn't take an explicit stopping policy defaults to `StoppingPolicy.shortest`. Instead of using the `std.range.Zip` struct that has a runtime-specifiable stopping policy we could use a nameless struct whose stopping policy is fixed at compile time. This would allow inferring @nogc and nothrow: having a runtime-settable StoppingPolicy is why `std.range.Zip` cannot infer those traits.
Comment #1 by n8sh.secondary — 2018-03-20T14:16:52Z
Comment #2 by github-bugzilla — 2018-03-30T01:38:52Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/259cf754bb42ad30039c1b82ea6d43109ecc6c9b Fix Issue 18638 - The main override of std.range.zip could infer @nogc and nothrow ZipShortest impl. a bit more efficient than Zip because doesn't need switch statements with code for each stopping policy. Also in some cases only needs to check one range for `empty` or `length` rather than all. Also correctly handles `back` when ranges have unequal lengths. https://github.com/dlang/phobos/commit/1db9cbedd8c1bf29256c60776b7cba214fb1cc0a Merge pull request #6307 from n8sh/zip-shortest Fix Issue 18638 - The main override of std.range.zip could infer @nogc and nothrow merged-on-behalf-of: Jack Stouffer <[email protected]>