[Issue 4114] Support static arrays in some algorithms

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 16 20:08:49 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4114


David Simcha <dsimcha at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha at yahoo.com


--- Comment #1 from David Simcha <dsimcha at yahoo.com> 2010-08-16 20:08:44 PDT ---
The issue I see here is that, since static arrays are usually stack allocated,
using them as ranges is inherently unsafe.  Even in cases where it seems safe,
the predicate may do weird things like escape the static array.  I think the
generic programming issue can be solved by simply having an unsafe function in
std.range:

auto toRange(R)(ref R stuff) if(isInputRange!R) {
    static if(isStaticArray!R) {
         return stuff[];
    } else {
        return stuff; 
    }
}

Of course, I'd also create an overload w/o the ref so it works with rvalues. 
Sound good?

-- 
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