wl_range

Returns a range that iterates over a wl_list. The member alias and the passed list is the wl_list member in a container struct, and the front type of the range is the container itself.

  1. WlListRange!member wl_range(wl_list* head)
    template wl_range(alias member)
    static
    WlListRange!member
    wl_range
  2. template wl_range(T)

Members

Static functions

wl_range
WlListRange!member wl_range(wl_list* head)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

struct Item
{
    int num;
    wl_list link;

    this(int num) { this.num = num; }
}
auto i1 = Item(1);
auto i2 = Item(2);
auto i3 = Item(3);

wl_list lst;
wl_list_init(&lst);
wl_list_insert(&lst, &i1.link);
wl_list_insert(&lst, &i2.link);
wl_list_insert(&i2.link, &i3.link);

int[] forw_arr;
foreach(it; wl_range!(Item.link)(&lst)) {
    forw_arr ~= it.num;
}
assert(forw_arr == [2, 3, 1]);

int[] back_arr;
foreach_reverse(it; wl_range!(Item.link)(&lst)) {
    back_arr ~= it.num;
}
assert(back_arr == [1, 3, 2]);

Meta