[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P1  |P3

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2022-06-10 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

Ali Cehreli  changed:

   What|Removed |Added

 CC||acehr...@yahoo.com

--- Comment #7 from Ali Cehreli  ---


(In reply to Basile-z from comment #6)
> Is this supposed to work now ?
> 
> 
> void main()
> {
> int[][] arr = void;

That is the problem. We can't use arr in any meaningful way because it already
has garbage number of garbage elements.

> arr.length = 10;

It reduces the length to 10 but all the elements are garbage.

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2020-03-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

Basile-z  changed:

   What|Removed |Added

 CC|b2.t...@gmx.com |

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2017-02-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

b2.t...@gmx.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||b2.t...@gmx.com
 Resolution|FIXED   |---

--- Comment #6 from b2.t...@gmx.com ---
Is this supposed to work now ?


void main()
{
int[][] arr = void;
arr.length = 10;

version(all)
{
import std.algorithm.iteration : each;
arr.each!((ref a){a.length = 10; a[] = -1;});
}
else
{
foreach(ref a; arr)
{
a.length = 10;
a[] = -1;
}
}
}

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2017-01-16 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

--- Comment #5 from github-bugzi...@puremagic.com ---
Commits pushed to newCTFE at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/f903de7bc6a507e787323d633679872c5c8e618c
Fix issue 16255 - std.algorithm.iteration.each on opApply doesn't support ref

https://github.com/dlang/phobos/commit/515b6a4ea2d9485a01efbf212357b623980bfa82
Merge pull request #4991 from wilzbach/fix-issue-16255-each-opApply

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2017-01-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/f903de7bc6a507e787323d633679872c5c8e618c
Fix issue 16255 - std.algorithm.iteration.each on opApply doesn't support ref

https://github.com/dlang/phobos/commit/515b6a4ea2d9485a01efbf212357b623980bfa82
Merge pull request #4991 from wilzbach/fix-issue-16255-each-opApply

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2016-12-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/f903de7bc6a507e787323d633679872c5c8e618c
Fix issue 16255 - std.algorithm.iteration.each on opApply doesn't support ref

https://github.com/dlang/phobos/commit/515b6a4ea2d9485a01efbf212357b623980bfa82
Merge pull request #4991 from wilzbach/fix-issue-16255-each-opApply

Fix issue 16255 - std.algorithm.iteration.each on opApply doesn't support

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2016-12-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2016-12-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

greenify  changed:

   What|Removed |Added

 CC||greeen...@gmail.com

--- Comment #2 from greenify  ---
> Except it doesn't work. When each accepts the iterable, it accepts it by 
> value. It should accept it by reference (if it's a class, it could take the 
> class reference by value). Otherwise, the point of using ref throughout each 
> is kind of useless.

A simple solution with `auto ref` for Iterables:

https://github.com/dlang/phobos/pull/4991

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2016-10-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

--- Comment #1 from Jon Degenhardt  ---
An example that appears related:

void main()
{
import std.algorithm : each;

int[] dynamicArray = [1, 2, 3, 4, 5];
int[5] staticArray = [1, 2, 3, 4, 5];

dynamicArray.each!((ref x) => x++);
assert(dynamicArray == [2, 3, 4, 5, 6]); // modified

staticArray.each!((ref x) => x++);
assert(staticArray == [1, 2, 3, 4, 5]);  // not modified

staticArray[].each!((ref x) => x++);
assert(staticArray == [2, 3, 4, 5, 6]);  // modified
}

Using a ref parameter works in the range cases, but not the static array case
(opApply).

--


[Issue 16255] std.algorithm.iteration.each on opApply doesn't support ref

2016-10-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16255

Jon Degenhardt  changed:

   What|Removed |Added

 CC||jrdemail2000-dl...@yahoo.co
   ||m

--