www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9589] New: Add hasEmpty template to std.range

reply d-bugmail puremagic.com writes:
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



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: -------
Feb 25 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9589


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



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: -------
Feb 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9589


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



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: -------
Feb 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9589




17:06:49 PST ---

 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: -------
Feb 25 2013
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Feb 25 2013