Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1744

Show
Ignore:
Timestamp:
07/11/10 23:55:22 (14 years ago)
Author:
dsimcha
Message:

array() should work with input ranges.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/array.d

    r1739 r1744  
    2222Returns a newly-allocated array consisting of a copy of the input 
    2323range $(D r). 
    2424 
    2525Example: 
    2626 
    2727---- 
    2828auto a = array([1, 2, 3, 4, 5][]); 
    2929assert(a == [ 1, 2, 3, 4, 5 ]); 
    3030---- 
    3131 */ 
    32 ElementType!Range[] array(Range)(Range r) if (isForwardRange!Range) 
     32ElementType!Range[] array(Range)(Range r) if (isInputRange!Range) 
    3333{ 
    3434    alias ElementType!Range E; 
    3535    static if (hasLength!Range) 
    3636    { 
    3737        if (r.empty) return null; 
    3838 
    3939        // Determines whether the GC should scan the array. 
    4040        auto blkInfo = (typeid(E).flags & 1) ? 
    4141                       cast(GC.BlkAttr) 0 : 
    4242                       GC.BlkAttr.NO_SCAN;