mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
EASY: factor implementations of range length into a mixin template
This commit is contained in:
parent
311f00f8ac
commit
71ff9d79c5
3 changed files with 30 additions and 92 deletions
|
@ -371,10 +371,7 @@ private struct _Cache(R, bool bidir)
|
|||
return source.empty;
|
||||
}
|
||||
|
||||
static if (hasLength!R) auto length() @property
|
||||
{
|
||||
return source.length;
|
||||
}
|
||||
mixin ImplementLength!source;
|
||||
|
||||
E front() @property
|
||||
{
|
||||
|
@ -641,15 +638,7 @@ private struct MapResult(alias fun, Range)
|
|||
}
|
||||
}
|
||||
|
||||
static if (hasLength!R)
|
||||
{
|
||||
@property auto length()
|
||||
{
|
||||
return _input.length;
|
||||
}
|
||||
|
||||
alias opDollar = length;
|
||||
}
|
||||
mixin ImplementLength!_input;
|
||||
|
||||
static if (hasSlicing!R)
|
||||
{
|
||||
|
@ -4373,13 +4362,7 @@ if (fun.length >= 1)
|
|||
}
|
||||
}
|
||||
|
||||
static if (hasLength!R)
|
||||
{
|
||||
@property size_t length()
|
||||
{
|
||||
return source.length;
|
||||
}
|
||||
}
|
||||
mixin ImplementLength!source;
|
||||
}
|
||||
|
||||
return Result(range, args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue