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

Changeset 1739

Show
Ignore:
Timestamp:
07/09/10 03:50:31 (14 years ago)
Author:
andrei
Message:

Removed specialization of put(a, e) for array and object because the definition in std.range fulfills it

Files:

Legend:

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

    r1733 r1739  
    5858            } 
    5959            r.popFront; 
    6060        } 
    6161        return result; 
    6262    } 
    6363    else 
    6464    { 
    6565        auto a = appender!(E[])(); 
    6666        foreach (e; r) 
    6767        { 
    68             a.put(e); 
     68            put(a, e); 
    6969        } 
    7070        return a.data; 
    7171    } 
    7272    // // 2. Initialize the memory 
    7373    // size_t constructedElements = 0; 
    7474    // scope(failure) 
    7575    // { 
    7676    //     // Deconstruct only what was constructed 
    7777    //     foreach_reverse (i; 0 .. constructedElements) 
    7878    //     { 
     
    435435        n -= 4; 
    436436        return decode(a, n); 
    437437    } 
    438438    else 
    439439    { 
    440440        throw new UtfException("Invalid UTF character at end of string"); 
    441441    } 
    442442} 
    443443 
    444444 
    445 /** 
     445/* 
    446446Implements the range interface primitive $(D put) for built-in 
    447447arrays. Due to the fact that nonmember functions can be called with 
    448448the first argument using the dot notation, $(D array.put(e)) is 
    449449equivalent to $(D put(array, e)). 
    450450 
    451451Example: 
    452452---- 
    453453void main() 
    454454{ 
    455455    int[] a = [ 1, 2, 3 ]; 
    456456    int[] b = a; 
    457457    a.put(5); 
    458458    assert(a == [ 2, 3 ]); 
    459459    assert(b == [ 5, 2, 3 ]); 
    460460} 
    461461---- 
    462462*/ 
    463 void put(T, E)(ref T[] a, E e) { assert(a.length); a[0] = e; a = a[1 .. $]; } 
     463alias std.range.put put; 
     464 //void put(T, E)(ref T[] a, E e) { assert(a.length); a[0] = e; a = a[1 .. $]; } 
    464465 
    465466// overlap 
    466467/* 
    467468Returns the overlapping portion, if any, of two arrays. Unlike $(D 
    468469equal), $(D overlap) only compares the pointers in the ranges, not the 
    469470values referred by them. If $(D r1) and $(D r2) have an overlapping 
    470471slice, returns that slice. Otherwise, returns the null slice. 
    471472 
    472473Example: 
    473474----