Quick updates to std.algorithm: Unquals in a few places to work w/ const ranges, re-add save() to Filter.

This commit is contained in:
David Simcha 2010-08-11 20:24:17 +00:00
parent 98aec1ce64
commit 7ca87c26ac

View file

@ -114,8 +114,8 @@ struct Map(alias fun, Range) if (isInputRange!(Range))
{ {
alias fun _fun; alias fun _fun;
alias typeof({ return _fun(.ElementType!(Range).init); }()) ElementType; alias typeof({ return _fun(.ElementType!(Range).init); }()) ElementType;
Range _input; Unqual!Range _input;
ElementType _cache; Unqual!ElementType _cache;
static if (isBidirectionalRange!(Range)) static if (isBidirectionalRange!(Range))
{ {
@ -724,7 +724,7 @@ filter(alias pred, Range)(Range rs)
struct Filter(alias pred, Range) if (isInputRange!(Range)) struct Filter(alias pred, Range) if (isInputRange!(Range))
{ {
Range _input; Unqual!Range _input;
this(Range r) this(Range r)
{ {
@ -750,6 +750,14 @@ struct Filter(alias pred, Range) if (isInputRange!(Range))
{ {
return _input.front; return _input.front;
} }
static if(isForwardRange!Range)
{
@property typeof(this) save()
{
return typeof(this)(_input);
}
}
} }
unittest unittest
@ -1504,7 +1512,7 @@ unittest
// joiner // joiner
/** /**
Lazily joins a range of ranges with a separator. The range of ranges Lazily joins a range of ranges with a separator. The range of ranges
Example: Example:
---- ----