Adapting foreign iterators to D ranges

cc cc at nevernet.com
Thu Apr 25 03:18:36 UTC 2024


On Wednesday, 24 April 2024 at 05:08:25 UTC, Salih Dincer wrote:
> Yes, `opApply()` works! You just need to use `do while()` 
> instead of `while()` because it skips the first item.

It depends on the type of structure being consumed, if it 
provides "next" as a direct pointer then yeah you would need to 
consume the item first before iterating to the next in line.  
However some APIs provide an opaque iterator type where you call 
a "next" method to get the first element, IIRC Lua does something 
like this.


More information about the Digitalmars-d-learn mailing list