joiner and map, strange behavior
Timon Gehr
timon.gehr at gmx.ch
Tue Mar 12 13:22:09 PDT 2013
On 03/12/2013 06:51 PM, Stephan Schiffels wrote:
> ...
>
> Thanks, I had a brief look at std.algorithm.joiner but couldn't find
> anything obvious, maybe I should look deeper into it.
> ...
I guess it is because of the following:
Eg (similar code occurs two times):
...
if (_sep.empty)
{
// Advance to the next range in the
// input
//_items.popFront();
for (;; _items.popFront())
{
if (_items.empty) return;
if (!_items.front.empty) break; // front called
}
_current = _items.front; // front called again
_items.popFront();
}
...
The code should only call front once for the first non-empty range.
Presumed example fix (though the implementation seems rather clumsy and
should probably be replaced completely):
...
if (_sep.empty)
{
// Advance to the next range in the
// input
//_items.popFront();
for (;; _items.popFront())
{
if (_items.empty) return;
_current = _items.front;
if (!_current.empty) break;
}
_items.popFront();
}
...
More information about the Digitalmars-d-learn
mailing list