Printing a range of ranges drains them

Salih Dincer salihdb at hotmail.com
Tue May 28 06:29:30 UTC 2024


On Tuesday, 28 May 2024 at 05:54:36 UTC, Salih Dincer wrote:
> On Monday, 27 May 2024 at 16:28:28 UTC, monkyyy wrote:
>> On Monday, 27 May 2024 at 00:25:42 UTC, Steven Schveighoffer 
>> wrote:
>>> 
>>> So, does anyone expect this behavior? If so, can you explain 
>>> why you think this is intentionally designed this way?
>>
>> This is correct behavior for ref front ranges with imperative 
>> pop
>
> Is the situation the same as this example?

There's no reason why this issue can't be easily fixed. Because 
when you include narrow string or wchar, there is no problem of 
not being able to save(). Here is the proof:
```d
void main()
{
   ushort[] i = [1, 2, 3];
   auto r = R(i);
   auto arr = [r, r, r];

   import std.conv : text;
   auto str = arr.text;
   assert(!arr.empty);

   foreach(n; arr)
   {
     n.writefln!"%(%d, %)";
   } // no problem
}
```

SDB at 79




More information about the Digitalmars-d mailing list