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

Changeset 1718

Show
Ignore:
Timestamp:
07/04/10 21:40:26 (14 years ago)
Author:
andrei
Message:

Fixed fix for Map.save

Files:

Legend:

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

    r1714 r1718  
    194194 
    195195    static if (hasSlicing!(Range)) { 
    196196        typeof(this) opSlice(size_t lowerBound, size_t upperBound) { 
    197197            return typeof(this)(_input[lowerBound..upperBound]); 
    198198        } 
    199199    } 
    200200 
    201201    static if (isForwardRange!Range) 
    202202        @property Map save() 
    203203        { 
    204             return this; 
     204            auto result = this; 
     205            result._input = result._input.save; 
     206            return result; 
    205207        } 
    206208} 
    207209 
    208210unittest 
    209211{ 
    210212    scope(failure) writeln("Unittest failed at line ", __LINE__); 
    211213    int[] arr1 = [ 1, 2, 3, 4 ]; 
    212214    int[] arr2 = [ 5, 6 ]; 
    213215    auto squares = map!("a * a")(arr1); 
    214216    assert(equal(squares, [ 1, 4, 9, 16 ][]));