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

Changeset 1711

Show
Ignore:
Timestamp:
07/03/10 13:50:21 (14 years ago)
Author:
dsimcha
Message:

std.array.back(): enforce -> assert.

Files:

Legend:

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

    r1587 r1711  
    381381void main() 
    382382{ 
    383383    int[] a = [ 1, 2, 3 ]; 
    384384    assert(a.front == 1); 
    385385} 
    386386---- 
    387387*/ 
    388388ref typeof(A.init[0]) back(A)(A a) if (is(typeof(A.init[0])) 
    389389        && !isNarrowString!A) 
    390390{ 
    391     enforce(a.length, "Attempting to fetch the back of an empty array"); 
     391    assert(a.length, "Attempting to fetch the back of an empty array"); 
    392392    return a[$ - 1]; 
    393393} 
    394394 
    395395dchar back(A)(A a) 
    396396if (is(typeof(A.init[0])) && isNarrowString!A && a[0].sizeof < 4) 
    397397{ 
    398398    assert(a.length, "Attempting to fetch the back of an empty array"); 
    399399    auto n = a.length; 
    400400    const p = a.ptr + n; 
    401401    if (n >= 1 && (p[-1] & 0b1100_0000) != 0b1000_0000)