mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 19:49:36 +03:00
add 'scope' to opApply() parameter
This commit is contained in:
parent
e75831ab22
commit
55e5737525
5 changed files with 10 additions and 10 deletions
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
|
|
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue