[Issue 9589] New: Add hasEmpty template to std.range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 25 16:13:39 PST 2013


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 at gmail.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at 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: -------


More information about the Digitalmars-d-bugs mailing list