mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 00:20:26 +03:00
iteration: use static class
This commit is contained in:
parent
9d8756f8b2
commit
cf3f60c359
1 changed files with 8 additions and 7 deletions
|
@ -1798,7 +1798,7 @@ if (isInputRange!R)
|
||||||
assert(equal(g3, [ tuple(1, 2u), tuple(2, 2u) ]));
|
assert(equal(g3, [ tuple(1, 2u), tuple(2, 2u) ]));
|
||||||
|
|
||||||
interface I {}
|
interface I {}
|
||||||
class C : I { override size_t toHash() const nothrow @safe { return 0; } }
|
static class C : I { override size_t toHash() const nothrow @safe { return 0; } }
|
||||||
const C[] a4 = [new const C()];
|
const C[] a4 = [new const C()];
|
||||||
auto g4 = a4.group!"a is b";
|
auto g4 = a4.group!"a is b";
|
||||||
assert(g4.front[1] == 1);
|
assert(g4.front[1] == 1);
|
||||||
|
@ -2255,25 +2255,26 @@ if (isForwardRange!Range)
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
|
|
||||||
size_t popCount = 0;
|
size_t popCount = 0;
|
||||||
class RefFwdRange
|
static class RefFwdRange
|
||||||
{
|
{
|
||||||
int[] impl;
|
int[] impl;
|
||||||
|
size_t* pcount;
|
||||||
|
|
||||||
@safe nothrow:
|
@safe nothrow:
|
||||||
|
|
||||||
this(int[] data) { impl = data; }
|
this(int[] data, size_t* pcount) { impl = data; this.pcount = pcount; }
|
||||||
@property bool empty() { return impl.empty; }
|
@property bool empty() { return impl.empty; }
|
||||||
@property auto ref front() { return impl.front; }
|
@property auto ref front() { return impl.front; }
|
||||||
void popFront()
|
void popFront()
|
||||||
{
|
{
|
||||||
impl.popFront();
|
impl.popFront();
|
||||||
popCount++;
|
(*pcount)++;
|
||||||
}
|
}
|
||||||
@property auto save() { return new RefFwdRange(impl); }
|
@property auto save() { return new RefFwdRange(impl, pcount); }
|
||||||
}
|
}
|
||||||
static assert(isForwardRange!RefFwdRange);
|
static assert(isForwardRange!RefFwdRange);
|
||||||
|
|
||||||
auto testdata = new RefFwdRange([1, 3, 5, 2, 4, 7, 6, 8, 9]);
|
auto testdata = new RefFwdRange([1, 3, 5, 2, 4, 7, 6, 8, 9], &popCount);
|
||||||
auto groups = testdata.chunkBy!((a,b) => (a % 2) == (b % 2));
|
auto groups = testdata.chunkBy!((a,b) => (a % 2) == (b % 2));
|
||||||
auto outerSave1 = groups.save;
|
auto outerSave1 = groups.save;
|
||||||
|
|
||||||
|
@ -6058,7 +6059,7 @@ if (is(typeof(binaryFun!pred(r.front, s.front)) : bool)
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
|
|
||||||
// Test by-reference separator
|
// Test by-reference separator
|
||||||
class RefSep {
|
static class RefSep {
|
||||||
@safe:
|
@safe:
|
||||||
string _impl;
|
string _impl;
|
||||||
this(string s) { _impl = s; }
|
this(string s) { _impl = s; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue