Skip to content

Commit

Permalink
Merge pull request #4787 from WalterBright/scope-opApply
Browse files Browse the repository at this point in the history
add 'scope' to opApply() parameter
  • Loading branch information
schveiguy committed Sep 15, 2016
2 parents e75831a + 55e5737 commit 3142577
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions std/algorithm/iteration.d
Expand Up @@ -982,7 +982,7 @@ template each(alias pred = "a")
static class S
{
int x;
int opApply(int delegate(ref int _x) dg) { return dg(x); }
int opApply(scope int delegate(ref int _x) dg) { return dg(x); }
}

auto s = new S;
Expand Down Expand Up @@ -2862,7 +2862,7 @@ The number of seeds must be correspondingly increased.
{
bool actEmpty;

int opApply(int delegate(ref int) dg)
int opApply(scope int delegate(ref int) dg)
{
int res;
if (actEmpty) return res;
Expand Down
2 changes: 1 addition & 1 deletion std/array.d
Expand Up @@ -221,7 +221,7 @@ ElementType!String[] array(String)(String str) if (isNarrowString!String)

static struct OpApply
{
int opApply(int delegate(ref int) dg)
int opApply(scope int delegate(ref int) dg)
{
int res;
foreach (i; 0..10)
Expand Down
4 changes: 2 additions & 2 deletions std/json.d
Expand Up @@ -616,7 +616,7 @@ struct JSONValue
}

/// Implements the foreach $(D opApply) interface for json arrays.
int opApply(int delegate(size_t index, ref JSONValue) dg) @system
int opApply(scope int delegate(size_t index, ref JSONValue) dg) @system
{
int result;

Expand All @@ -631,7 +631,7 @@ struct JSONValue
}

/// Implements the foreach $(D opApply) interface for json objects.
int opApply(int delegate(string key, ref JSONValue) dg) @system
int opApply(scope int delegate(string key, ref JSONValue) dg) @system
{
enforce!JSONException(type == JSON_TYPE.OBJECT,
"JSONValue is not an object");
Expand Down
8 changes: 4 additions & 4 deletions std/range/interfaces.d
Expand Up @@ -110,10 +110,10 @@ interface InputRange(E) {
/**$(D foreach) iteration uses opApply, since one delegate call per loop
* iteration is faster than three virtual function calls.
*/
int opApply(int delegate(E));
int opApply(scope int delegate(E));

/// Ditto
int opApply(int delegate(size_t, E));
int opApply(scope int delegate(size_t, E));

}

Expand Down Expand Up @@ -436,7 +436,7 @@ if (isInputRange!(Unqual!R))

// Optimization: One delegate call is faster than three virtual
// function calls. Use opApply for foreach syntax.
int opApply(int delegate(E) dg) {
int opApply(scope int delegate(E) dg) {
int res;

for (auto r = _range; !r.empty; r.popFront())
Expand All @@ -448,7 +448,7 @@ if (isInputRange!(Unqual!R))
return res;
}

int opApply(int delegate(size_t, E) dg) {
int opApply(scope int delegate(size_t, E) dg) {
int res;

size_t i = 0;
Expand Down
2 changes: 1 addition & 1 deletion std/traits.d
Expand Up @@ -5633,7 +5633,7 @@ enum bool isIterable(T) = is(typeof({ foreach (elem; T.init) {} }));
{
struct OpApply
{
int opApply(int delegate(ref uint) dg) { assert(0); }
int opApply(scope int delegate(ref uint) dg) { assert(0); }
}

struct Range
Expand Down

0 comments on commit 3142577

Please sign in to comment.