mirror of
https://github.com/dlang/phobos.git
synced 2025-05-06 11:07:39 +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
|
static class S
|
||||||
{
|
{
|
||||||
int x;
|
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;
|
auto s = new S;
|
||||||
|
@ -2862,7 +2862,7 @@ The number of seeds must be correspondingly increased.
|
||||||
{
|
{
|
||||||
bool actEmpty;
|
bool actEmpty;
|
||||||
|
|
||||||
int opApply(int delegate(ref int) dg)
|
int opApply(scope int delegate(ref int) dg)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if (actEmpty) return res;
|
if (actEmpty) return res;
|
||||||
|
|
|
@ -221,7 +221,7 @@ ElementType!String[] array(String)(String str) if (isNarrowString!String)
|
||||||
|
|
||||||
static struct OpApply
|
static struct OpApply
|
||||||
{
|
{
|
||||||
int opApply(int delegate(ref int) dg)
|
int opApply(scope int delegate(ref int) dg)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
foreach (i; 0..10)
|
foreach (i; 0..10)
|
||||||
|
|
|
@ -616,7 +616,7 @@ struct JSONValue
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements the foreach $(D opApply) interface for json arrays.
|
/// 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;
|
int result;
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ struct JSONValue
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements the foreach $(D opApply) interface for json objects.
|
/// 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,
|
enforce!JSONException(type == JSON_TYPE.OBJECT,
|
||||||
"JSONValue is not an object");
|
"JSONValue is not an object");
|
||||||
|
|
|
@ -110,10 +110,10 @@ interface InputRange(E) {
|
||||||
/**$(D foreach) iteration uses opApply, since one delegate call per loop
|
/**$(D foreach) iteration uses opApply, since one delegate call per loop
|
||||||
* iteration is faster than three virtual function calls.
|
* iteration is faster than three virtual function calls.
|
||||||
*/
|
*/
|
||||||
int opApply(int delegate(E));
|
int opApply(scope int delegate(E));
|
||||||
|
|
||||||
/// Ditto
|
/// 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
|
// Optimization: One delegate call is faster than three virtual
|
||||||
// function calls. Use opApply for foreach syntax.
|
// function calls. Use opApply for foreach syntax.
|
||||||
int opApply(int delegate(E) dg) {
|
int opApply(scope int delegate(E) dg) {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
for (auto r = _range; !r.empty; r.popFront())
|
for (auto r = _range; !r.empty; r.popFront())
|
||||||
|
@ -448,7 +448,7 @@ if (isInputRange!(Unqual!R))
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int opApply(int delegate(size_t, E) dg) {
|
int opApply(scope int delegate(size_t, E) dg) {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
|
@ -5633,7 +5633,7 @@ enum bool isIterable(T) = is(typeof({ foreach (elem; T.init) {} }));
|
||||||
{
|
{
|
||||||
struct OpApply
|
struct OpApply
|
||||||
{
|
{
|
||||||
int opApply(int delegate(ref uint) dg) { assert(0); }
|
int opApply(scope int delegate(ref uint) dg) { assert(0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Range
|
struct Range
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue