Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 26, 2013 [Issue 9589] New: Add hasEmpty template to std.range | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9589 Summary: Add hasEmpty template to std.range Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: andrej.mitrovich@gmail.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-25 16:13:37 PST --- In one of my templated functions I've misused the hasLength template to figure out if I can call ".empty" on a type: void add(E elem) { static if (hasLength!E) if (elem.empty) return; // do something with 'elem' } Unfortunately this won't work with strings because hasLength returns false for strings (it's deliberate, but I missed this part of the docs). Anyway the proper template I should use is 'hasEmpty', which is missing from phobos. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 26, 2013 [Issue 9589] Add hasEmpty template to std.range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9589 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-25 16:20:05 PST --- https://github.com/D-Programming-Language/phobos/pull/1175 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 26, 2013 [Issue 9589] Add hasEmpty template to std.range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9589 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2013-02-25 16:58:58 PST --- I don't know that it's necessarily a bad idea to add this, but _all_ ranges have empty by definition. isInputRange requires it, so if you're dealing with range-based stuff, there's no point in checking for hasEmpty. It's already guaranteed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 26, 2013 [Issue 9589] Add hasEmpty template to std.range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9589 --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-25 17:06:49 PST --- (In reply to comment #2) > I don't know that it's necessarily a bad idea to add this, but _all_ ranges have empty by definition. Hmm yeah, isInputRange would actually work here. Knowing this now I'm on the fence of whether the enhancement is worth adding. Perhaps non-range types could implement "empty", but in that case this doesn't belong to std.range. I guess we can close it then. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 26, 2013 [Issue 9589] Add hasEmpty template to std.range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9589 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation