Bug 6409 – std.array.empty for associative arrays too

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-30T06:57:28Z
Last change time
2017-10-16T09:57:50Z
Keywords
bootcamp
Assigned to
No Owner
Creator
bearophile_hugs
Depends on
17894

Comments

Comment #0 by bearophile_hugs — 2011-07-30T06:57:28Z
I suggest to extend std.array.empty to work with associative arrays too: import std.array; void main() { int[] a; assert(a.empty); // OK int[int] aa; assert(aa.empty); // Error } DMD 2.054: test.d(6): Error: template std.array.empty(T) does not match any function template declaration test.d(6): Error: template std.array.empty(T) cannot deduce template function from argument types !()(int[int])
Comment #1 by jack — 2016-06-27T19:57:06Z
What's the rationale? Why not just aa.length == 0?
Comment #2 by razvan.nitu1305 — 2017-09-07T12:42:41Z
I agree with @JackStouffer here, I don't see the point when you have aa.length. Should we close this?
Comment #3 by andrei — 2017-09-07T15:04:47Z
Let's support empty for AAs for uniformity. Thanks.
Comment #4 by petar.p.kirov — 2017-10-11T10:45:27Z
Comment #5 by github-bugzilla — 2017-10-12T10:27:58Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/bf1c17838214d596f6e388929ad7e22147ba09f8 Fix Issue 6409 - std.array.empty for associative arrays too https://github.com/dlang/phobos/commit/5a9cbe9c30647f1acc9736adaf33eca63693e706 Merge pull request #5726 from RazvanN7/Issue_6409 Fix Issue 6409 - std.array.empty for associative arrays too merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
Comment #6 by github-bugzilla — 2017-10-16T09:57:50Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/bf1c17838214d596f6e388929ad7e22147ba09f8 Fix Issue 6409 - std.array.empty for associative arrays too https://github.com/dlang/phobos/commit/5a9cbe9c30647f1acc9736adaf33eca63693e706 Merge pull request #5726 from RazvanN7/Issue_6409