Changeset 1688
- Timestamp:
- 06/23/10 12:45:32 (14 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/algorithm.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1685 r1688 2 2 3 3 $(D_S D Change Log, 4 4 5 5 6 6 $(VERSION 048, Jun 11, 2010, =================================================, 7 7 8 8 $(WHATSNEW 9 9 $(LI std.string: icmp() now works with all built-in string types.) 10 10 ) 11 11 $(BUGSFIXED 12 $(L1 $(Unlisted Bug): std.algorithm.filter not a forward range. 12 13 $(LI $(BUGZILLA 978): std.utf's toUTF* functions accept some invalid and reject some valid UTF) 13 14 $(LI $(BUGZILLA 996): Error in doc on implicit conversion between pointer and array) 14 15 $(LI $(BUGZILLA 2275): std.utf.toUTF16z() should return const(wchar)*) 15 16 $(LI $(BUGZILLA 2872): Length, opIndex for Map) 16 17 $(LI $(BUGZILLA 3202): std.math.pow cause dead loop) 17 18 $(LI $(BUGZILLA 3355): std.string.cmp works incorrectly for mixed-type and different-length strings) 18 19 $(LI $(BUGZILLA 3386): to!bool(string) is not implemented) 19 20 $(LI $(BUGZILLA 3436): std.functional.compose with only one function) 20 21 $(LI $(BUGZILLA 3439): std.range.Sequence.opIndex not consistent after calling popFront().) 21 22 $(LI $(BUGZILLA 3447): std.file uses unconventional file permissions) 22 23 $(LI $(BUGZILLA 3961): Error with to!(somestruct)) 23 24 $(LI $(BUGZILLA 4109): (reopened) writeln doesn't work with empty static array) 24 25 $(LI $(BUGZILLA 4171): std.random.uniform does not work for a range of characters) 25 26 $(LI $(BUGZILLA 4327): std.container.Array.Range.~this() tries to call free(T[])) 27 $(LI $(BUGZILLA 4362): std.range.repeat and cycle do not have a .save() method 26 28 $(LI $(BUGZILLA 4363): std.algorithm.Until is not a forward range) 27 29 ) 28 30 ) 29 31 30 32 <div id=version> 31 33 $(UL 32 34 $(NEW 048) 33 35 $(NEW 047) 34 36 $(NEW 046) 35 37 $(NEW 045) trunk/phobos/std/algorithm.d
r1682 r1688 574 574 { 575 575 do 576 576 { 577 577 _input.popFront; 578 578 } while (!_input.empty && !pred(_input.front)); 579 579 } 580 580 581 581 ElementType!(Range) front() 582 582 { 583 583 return _input.front; 584 } 585 586 static if(isForwardRange!Range) 587 { 588 @property typeof(this) save() 589 { 590 return typeof(this)(_input.save); 591 } 584 592 } 585 593 } 586 594 587 595 unittest 588 596 { 589 597 int[] a = [ 3, 4 ]; 590 598 auto r = filter!("a > 3")(a); 591 599 assert(equal(r, [ 4 ][])); 600 static assert(isForwardRange!(typeof(r))); 592 601 593 602 a = [ 1, 22, 3, 42, 5 ]; 594 603 auto under10 = filter!("a < 10")(a); 595 604 assert(equal(under10, [1, 3, 5][])); 596 605 static assert(isForwardRange!(typeof(under10))); 606 597 607 auto infinite = filter!"a > 2"(repeat(3)); 598 608 static assert(isInfinite!(typeof(infinite))); 609 static assert(isForwardRange!(typeof(infinite))); 599 610 } 600 611 601 612 // move 602 613 /** 603 614 Moves $(D source) into $(D target) via a destructive 604 615 copy. Specifically: $(UL $(LI If $(D hasAliasing!T) is true (see 605 616 $(XREF traits, hasAliasing)), then the representation of $(D source) 606 617 is bitwise copied into $(D target) and then $(D source = T.init) is 607 618 evaluated.) $(LI Otherwise, $(D target = source) is evaluated.)) See 608 619 also $(XREF contracts, pointsTo).
