Gneric linkedList range adaptor

Ali Çehreli acehreli at
Fri Feb 10 23:43:06 UTC 2023

On 2/10/23 14:10, Ben Jones wrote:

 > Any idea how to fix the helper method?

I came up with the following solution:

 > struct LinkedListAdaptor(alias nextField, T){

In this case nextField will be a callable (a lambda below).

 >      void popFront() {
 >          current = __traits(child, current, nextField);

I changed that to

         current = nextField(current);

 >      auto rng1 = LinkedListAdaptor!(, Node*)(head);

Commented that out.

 >      auto rng = linkedListAdaptor!(;

Replaced that with

     auto rng = linkedListAdaptor!(node =>;

Now it works but explicitly creating a lambda feels less than ideal. 
Perhaps it can be improved.


More information about the Digitalmars-d-learn mailing list