Skip to content

Commit 91e7ed3

Browse files
committed
adopt for dip1000
1 parent f9e5bad commit 91e7ed3

3 files changed

Lines changed: 58 additions & 42 deletions

File tree

source/mir/algorithm/iteration.d

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,12 @@ package(mir) template allFlattened(args...)
603603
static if (args.length)
604604
{
605605
alias arg = args[0];
606-
@optmath @property ls()()
606+
@optmath @property allFlattenedMod()()
607607
{
608608
import mir.ndslice.topology: flattened;
609609
return flattened(arg);
610610
}
611-
alias allFlattened = AliasSeq!(ls, allFlattened!(args[1..$]));
611+
alias allFlattened = AliasSeq!(allFlattenedMod, allFlattened!(args[1..$]));
612612
}
613613
else
614614
alias allFlattened = AliasSeq!();
@@ -697,7 +697,7 @@ else
697697
private enum Mir_disable_inlining_in_reduce = false;
698698
}
699699

700-
S reduceImpl(alias fun, S, Slices...)(S seed, scope Slices slices)
700+
S reduceImpl(alias fun, S, Slices...)(S seed, Slices slices)
701701
{
702702
do
703703
{
@@ -744,7 +744,7 @@ template reduce(alias fun)
744744
Returns:
745745
the accumulated `result`
746746
+/
747-
@optmath auto reduce(S, Slices...)(S seed, scope Slices slices)
747+
@optmath auto reduce(S, Slices...)(S seed, Slices slices)
748748
if (Slices.length)
749749
{
750750
static if (Slices.length > 1)
@@ -767,7 +767,7 @@ template reduce(alias fun)
767767
}
768768
else version(Mir_disable_inlining_in_reduce)
769769
//As above, but with inlining disabled.
770-
@optmath auto reduce(S, Slices...)(S seed, scope Slices slices)
770+
@optmath auto reduce(S, Slices...)(S seed, Slices slices)
771771
if (Slices.length)
772772
{
773773
static if (Slices.length > 1)
@@ -952,7 +952,7 @@ version(mir_test) unittest
952952
assert(a == 7);
953953
}
954954

955-
void eachImpl(alias fun, Slices...)(scope Slices slices)
955+
void eachImpl(alias fun, Slices...)(Slices slices)
956956
{
957957
foreach(ref slice; slices)
958958
assert(!slice.empty);
@@ -961,14 +961,14 @@ void eachImpl(alias fun, Slices...)(scope Slices slices)
961961
static if (DimensionCount!(Slices[0]) == 1)
962962
fun(frontOf!slices);
963963
else
964-
.eachImpl!fun(frontOf!slices);
964+
.eachImpl!fun(frontOf2!slices);
965965
foreach_reverse(i; Iota!(Slices.length))
966966
slices[i].popFront;
967967
}
968968
while(!slices[0].empty);
969969
}
970970

971-
void chequerEachImpl(alias fun, Slices...)(Chequer color, scope Slices slices)
971+
void chequerEachImpl(alias fun, Slices...)(Chequer color, Slices slices)
972972
{
973973
foreach(ref slice; slices)
974974
assert(!slice.empty);
@@ -1116,7 +1116,7 @@ template each(alias fun)
11161116
Params:
11171117
slices = One or more slices, ranges, and arrays.
11181118
+/
1119-
@optmath auto each(Slices...)(scope Slices slices)
1119+
@optmath auto each(Slices...)(Slices slices)
11201120
if (Slices.length && !is(Slices[0] : Chequer))
11211121
{
11221122
static if (Slices.length > 1)
@@ -1140,7 +1140,7 @@ template each(alias fun)
11401140
color = $(LREF Chequer).
11411141
slices = One or more slices.
11421142
+/
1143-
@optmath auto each(Slices...)(Chequer color, scope Slices slices)
1143+
@optmath auto each(Slices...)(Chequer color, Slices slices)
11441144
if (Slices.length && allSatisfy!(isSlice, Slices))
11451145
{
11461146
static if (Slices.length > 1)
@@ -2139,7 +2139,7 @@ version(mir_test) unittest
21392139
assert(bi == [0, 0]);
21402140
}
21412141

2142-
size_t anyImpl(alias fun, Slices...)(scope Slices slices)
2142+
size_t anyImpl(alias fun, Slices...)(Slices slices)
21432143
if (Slices.length)
21442144
{
21452145
static if (__traits(isSame, fun, naryFun!"a") && is(S : Slice!(FieldIterator!(BitField!(Field, I))), Field, I))
@@ -2164,7 +2164,7 @@ size_t anyImpl(alias fun, Slices...)(scope Slices slices)
21642164
}
21652165
else
21662166
{
2167-
if (anyImpl!fun(frontOf!slices))
2167+
if (anyImpl!fun(frontOf2!slices))
21682168
return true;
21692169
}
21702170
foreach_reverse(ref slice; slices)
@@ -2195,7 +2195,7 @@ template any(alias pred = "a")
21952195
Constraints:
21962196
All slices must have the same shape.
21972197
+/
2198-
@optmath bool any(Slices...)(scope Slices slices)
2198+
@optmath bool any(Slices...)(Slices slices)
21992199
if ((Slices.length == 1 || !__traits(isSame, pred, "a")) && Slices.length)
22002200
{
22012201
static if (Slices.length > 1)
@@ -2299,7 +2299,7 @@ version(mir_test) unittest
22992299
[8, 8, 5]]);
23002300
}
23012301

2302-
size_t allImpl(alias fun, Slices...)(scope Slices slices)
2302+
size_t allImpl(alias fun, Slices...)(Slices slices)
23032303
if (Slices.length)
23042304
{
23052305
static if (__traits(isSame, fun, naryFun!"a") && is(S : Slice!(FieldIterator!(BitField!(Field, I))), Field, I))
@@ -2324,7 +2324,7 @@ size_t allImpl(alias fun, Slices...)(scope Slices slices)
23242324
}
23252325
else
23262326
{
2327-
if (!allImpl!fun(frontOf!slices))
2327+
if (!allImpl!fun(frontOf2!slices))
23282328
return false;
23292329
}
23302330
foreach_reverse(ref slice; slices)
@@ -2355,7 +2355,7 @@ template all(alias pred = "a")
23552355
Constraints:
23562356
All slices must have the same shape.
23572357
+/
2358-
@optmath bool all(Slices...)(scope Slices slices)
2358+
@optmath bool all(Slices...)(Slices slices)
23592359
if ((Slices.length == 1 || !__traits(isSame, pred, "a")) && Slices.length)
23602360
{
23612361
static if (Slices.length > 1)
@@ -2485,7 +2485,7 @@ template count(alias fun)
24852485
Constraints:
24862486
All slices must have the same shape.
24872487
+/
2488-
@optmath size_t count(Slices...)(scope Slices slices)
2488+
@optmath size_t count(Slices...)(Slices slices)
24892489
if (Slices.length)
24902490
{
24912491
static if (Slices.length > 1)
@@ -2605,7 +2605,7 @@ template equal(alias pred = "a == b")
26052605
Returns:
26062606
`true` any of the elements verify `pred` and `false` otherwise.
26072607
+/
2608-
bool equal(Slices...)(scope Slices slices)
2608+
bool equal(Slices...)(Slices slices)
26092609
if (Slices.length >= 2)
26102610
{
26112611
import mir.internal.utility;
@@ -2823,7 +2823,7 @@ version(mir_test) unittest
28232823
assert(cmp(sl1[0 .. $ - 1, 0 .. $ - 3], sl1[0 .. $, 0 .. $ - 3]) < 0);
28242824
}
28252825

2826-
size_t countImpl(alias fun, Slices...)(scope Slices slices)
2826+
size_t countImpl(alias fun, Slices...)(Slices slices)
28272827
{
28282828
size_t ret;
28292829
alias S = Slices[0];
@@ -2850,7 +2850,7 @@ size_t countImpl(alias fun, Slices...)(scope Slices slices)
28502850
ret++;
28512851
}
28522852
else
2853-
ret += .countImpl!fun(frontOf!slices);
2853+
ret += .countImpl!fun(frontOf2!slices);
28542854
foreach_reverse(ref slice; slices)
28552855
slice.popFront;
28562856
}

source/mir/ndslice/internal.d

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,25 @@ package(mir) template frontOf(args...)
365365
enum frontOf = args;
366366
else
367367
{
368-
@optmath @property auto ref ls()()
368+
@optmath @property auto ref frontOfMod()()
369+
{
370+
return args[0].front;
371+
}
372+
alias frontOf = AliasSeq!(frontOfMod, frontOf!(args[1..$]));
373+
}
374+
}
375+
376+
package(mir) template frontOf2(args...)
377+
{
378+
static if (args.length == 0)
379+
enum frontOf2 = args;
380+
else
381+
{
382+
@optmath @property auto frontOf2Mod()()
369383
{
370384
return args[0].front;
371385
}
372-
alias frontOf = AliasSeq!(ls, frontOf!(args[1..$]));
386+
alias frontOf2 = AliasSeq!(frontOf2Mod, frontOf2!(args[1..$]));
373387
}
374388
}
375389

@@ -379,11 +393,11 @@ package(mir) template backOf(args...)
379393
enum backOf = args;
380394
else
381395
{
382-
@optmath @property auto ref ls()()
396+
@optmath @property auto ref backOfMod()()
383397
{
384398
return args[0].back;
385399
}
386-
alias backOf = AliasSeq!(ls, backOf!(args[1..$]));
400+
alias backOf = AliasSeq!(backOfMod, backOf!(args[1..$]));
387401
}
388402
}
389403

@@ -393,11 +407,11 @@ package(mir) template frontOfD(size_t dimension, args...)
393407
enum frontOfD = args;
394408
else
395409
{
396-
@optmath @property auto ref ls()()
410+
@optmath @property auto ref frontOfDMod()()
397411
{
398412
return args[0].front!dimension;
399413
}
400-
alias frontOfD = AliasSeq!(ls, frontOfD!(dimension, args[1..$]));
414+
alias frontOfD = AliasSeq!(frontOfDMod, frontOfD!(dimension, args[1..$]));
401415
}
402416
}
403417

@@ -407,11 +421,11 @@ package(mir) template backOfD(size_t dimension, args...)
407421
enum backOfD = args;
408422
else
409423
{
410-
@optmath @property auto ref ls()()
424+
@optmath @property auto ref backOfDMod()()
411425
{
412426
return args[0].back!dimension;
413427
}
414-
alias backOfD = AliasSeq!(ls, backOfD!(dimension, args[1..$]));
428+
alias backOfD = AliasSeq!(backOfDMod, backOfD!(dimension, args[1..$]));
415429
}
416430
}
417431

@@ -422,11 +436,11 @@ package(mir) template frontOfDim(size_t dim, args...)
422436
else
423437
{
424438
alias arg = args[0];
425-
@optmath @property auto ref ls()
439+
@optmath @property auto ref frontOfDimMod()
426440
{
427441
return arg.front!dim;
428442
}
429-
alias frontOfDim = AliasSeq!(ls, frontOfDim!(dim, args[1..$]));
443+
alias frontOfDim = AliasSeq!(frontOfDimMod, frontOfDim!(dim, args[1..$]));
430444
}
431445
}
432446

@@ -437,11 +451,11 @@ package(mir) template selectFrontOf(alias input, args...)
437451
else
438452
{
439453
alias arg = args[0];
440-
@optmath @property auto ref ls()()
454+
@optmath @property auto ref selectFrontOfMod()()
441455
{
442456
return arg.lightScope.selectFront!0(input);
443457
}
444-
alias selectFrontOf = AliasSeq!(ls, selectFrontOf!(input, args[1..$]));
458+
alias selectFrontOf = AliasSeq!(selectFrontOfMod, selectFrontOf!(input, args[1..$]));
445459
}
446460
}
447461

@@ -452,11 +466,11 @@ package(mir) template selectBackOf(alias input, args...)
452466
else
453467
{
454468
alias arg = args[0];
455-
@optmath @property auto ref ls()()
469+
@optmath @property auto ref selectBackOfMod()()
456470
{
457471
return arg.selectBack!0(input);
458472
}
459-
alias selectBackOf = AliasSeq!(ls, selectBackOf!(input, args[1..$]));
473+
alias selectBackOf = AliasSeq!(selectBackOfMod, selectBackOf!(input, args[1..$]));
460474
}
461475
}
462476

@@ -467,11 +481,11 @@ package(mir) template frontSelectFrontOf(alias input, args...)
467481
else
468482
{
469483
alias arg = args[0];
470-
@optmath @property auto ref ls()()
484+
@optmath @property auto ref frontSelectFrontOfMod()()
471485
{
472486
return arg.lightScope.front.selectFront!0(input);
473487
}
474-
alias frontSelectFrontOf = AliasSeq!(ls, frontSelectFrontOf!(input, args[1..$]));
488+
alias frontSelectFrontOf = AliasSeq!(frontSelectFrontOfMod, frontSelectFrontOf!(input, args[1..$]));
475489
}
476490
}
477491

@@ -482,10 +496,12 @@ package(mir) template frontSelectBackOf(alias input, args...)
482496
else
483497
{
484498
alias arg = args[0];
485-
@optmath @property auto ref ls()()
499+
@optmath @property auto ref frontSelectBackOfMod
500+
()()
486501
{
487502
return arg.lightScope.front.selectBack!0(input);
488503
}
489-
alias frontSelectBackOf = AliasSeq!(ls, frontSelectBackOf!(input, args[1..$]));
504+
alias frontSelectBackOf = AliasSeq!(frontSelectBackOfMod
505+
, frontSelectBackOf!(input, args[1..$]));
490506
}
491507
}

source/mir/ndslice/slice.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,15 @@ package(mir) template allLightScope(args...)
477477
static if(!isDynamicArray!Arg)
478478
{
479479
static if(!is(LightScopeOf!Arg == Arg))
480-
@optmath @property ls()()
480+
@optmath @property allLightScopeMod()()
481481
{
482482
import mir.qualifier: lightScope;
483483
return lightScope(arg);
484484
}
485-
else alias ls = arg;
485+
else alias allLightScopeMod = arg;
486486
}
487-
else alias ls = arg;
488-
alias allLightScope = AliasSeq!(ls, allLightScope!(args[1..$]));
487+
else alias allLightScopeMod = arg;
488+
alias allLightScope = AliasSeq!(allLightScopeMod, allLightScope!(args[1..$]));
489489
}
490490
else
491491
alias allLightScope = AliasSeq!();

0 commit comments

Comments
 (0)