mirror of
https://github.com/dlang/phobos.git
synced 2025-05-05 17:42:58 +03:00
std.range.package: Reduce maximum line length
This commit is contained in:
parent
9bd2f2ba8f
commit
782af8cb89
1 changed files with 30 additions and 9 deletions
|
@ -656,12 +656,14 @@ do
|
||||||
static if (hasSlicing!R && hasLength!R)
|
static if (hasSlicing!R && hasLength!R)
|
||||||
typeof(this) opSlice(size_t lower, size_t upper)
|
typeof(this) opSlice(size_t lower, size_t upper)
|
||||||
{
|
{
|
||||||
assert(upper >= lower && upper <= length, "Attempt to get out-of-bounds slice of `stride` range");
|
assert(upper >= lower && upper <= length,
|
||||||
|
"Attempt to get out-of-bounds slice of `stride` range");
|
||||||
immutable translatedUpper = (upper == 0) ? 0 :
|
immutable translatedUpper = (upper == 0) ? 0 :
|
||||||
(upper * _n - (_n - 1));
|
(upper * _n - (_n - 1));
|
||||||
immutable translatedLower = min(lower * _n, translatedUpper);
|
immutable translatedLower = min(lower * _n, translatedUpper);
|
||||||
|
|
||||||
assert(translatedLower <= translatedUpper, "Overflow when calculating slice of `stride` range");
|
assert(translatedLower <= translatedUpper,
|
||||||
|
"Overflow when calculating slice of `stride` range");
|
||||||
|
|
||||||
return typeof(this)(source[translatedLower .. translatedUpper], _n);
|
return typeof(this)(source[translatedLower .. translatedUpper], _n);
|
||||||
}
|
}
|
||||||
|
@ -6326,7 +6328,8 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
|
||||||
{
|
{
|
||||||
if (current < pastLast)
|
if (current < pastLast)
|
||||||
{
|
{
|
||||||
assert(unsigned(pastLast - current) <= size_t.max, "`iota` range is too long");
|
assert(unsigned(pastLast - current) <= size_t.max,
|
||||||
|
"`iota` range is too long");
|
||||||
|
|
||||||
this.current = current;
|
this.current = current;
|
||||||
this.pastLast = pastLast;
|
this.pastLast = pastLast;
|
||||||
|
@ -6339,17 +6342,34 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@property bool empty() const { return current == pastLast; }
|
@property bool empty() const { return current == pastLast; }
|
||||||
@property inout(Value) front() inout { assert(!empty, "Attempt to access `front` of empty `iota` range"); return current; }
|
@property inout(Value) front() inout
|
||||||
void popFront() { assert(!empty, "Attempt to `popFront` of empty `iota` range"); ++current; }
|
{
|
||||||
|
assert(!empty, "Attempt to access `front` of empty `iota` range");
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
void popFront()
|
||||||
|
{
|
||||||
|
assert(!empty, "Attempt to `popFront` of empty `iota` range");
|
||||||
|
++current;
|
||||||
|
}
|
||||||
|
|
||||||
@property inout(Value) back() inout { assert(!empty, "Attempt to access `back` of empty `iota` range"); return cast(inout(Value))(pastLast - 1); }
|
@property inout(Value) back() inout
|
||||||
void popBack() { assert(!empty, "Attempt to `popBack` of empty `iota` range"); --pastLast; }
|
{
|
||||||
|
assert(!empty, "Attempt to access `back` of empty `iota` range");
|
||||||
|
return cast(inout(Value))(pastLast - 1);
|
||||||
|
}
|
||||||
|
void popBack()
|
||||||
|
{
|
||||||
|
assert(!empty, "Attempt to `popBack` of empty `iota` range");
|
||||||
|
--pastLast;
|
||||||
|
}
|
||||||
|
|
||||||
@property auto save() { return this; }
|
@property auto save() { return this; }
|
||||||
|
|
||||||
inout(Value) opIndex(size_t n) inout
|
inout(Value) opIndex(size_t n) inout
|
||||||
{
|
{
|
||||||
assert(n < this.length, "Attempt to read out-of-bounds index of `iota` range");
|
assert(n < this.length,
|
||||||
|
"Attempt to read out-of-bounds index of `iota` range");
|
||||||
|
|
||||||
// Just cast to Value here because doing so gives overflow behavior
|
// Just cast to Value here because doing so gives overflow behavior
|
||||||
// consistent with calling popFront() n times.
|
// consistent with calling popFront() n times.
|
||||||
|
@ -6364,7 +6384,8 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
|
||||||
inout(Result) opSlice() inout { return this; }
|
inout(Result) opSlice() inout { return this; }
|
||||||
inout(Result) opSlice(ulong lower, ulong upper) inout
|
inout(Result) opSlice(ulong lower, ulong upper) inout
|
||||||
{
|
{
|
||||||
assert(upper >= lower && upper <= this.length, "Attempt to get out-of-bounds slice of `iota` range");
|
assert(upper >= lower && upper <= this.length,
|
||||||
|
"Attempt to get out-of-bounds slice of `iota` range");
|
||||||
|
|
||||||
return cast(inout Result) Result(cast(Value)(current + lower),
|
return cast(inout Result) Result(cast(Value)(current + lower),
|
||||||
cast(Value)(pastLast - (length - upper)));
|
cast(Value)(pastLast - (length - upper)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue