opApply and attributes

Ali Çehreli acehreli at yahoo.com
Tue Jul 7 20:53:05 UTC 2020


On 7/6/20 5:20 PM, solidstate1991 wrote:> See implementation of data 
structure here:
 > 
https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 

 >
 >
 > If I try to compile this code, it'll fail, limiting it's usecase:
 >
 > @safe pure unittest {
 >      alias IntMap = TreeMap!(int, int, false);
 >      IntMap test;
 >      test[5] = 5;
 >      test[7] = 7;
 >      test[3] = 3;
 >      foreach(elem, key; test) {
 >          assert(elem == key);
 >      }
 > }

I am not sure whether I understand it correctly but there has been a 
request for opApply() to gain the attributes of the delegate (or the 
range?). In other words, "transfer the attributes to opApply". This is 
needed because I want opApply() to work with any foreach body, 
attributes of which opApply() cannot know.

I am sure I created an issue on Dlang bug tracker for Weka on this topic 
but I can't find it now. (Aside: The search boxes on the bug tracker are 
inferior to the automatic search feature that works when creating a 
bug.) Anyway, this one seems related:

   https://issues.dlang.org/show_bug.cgi?id=7543

Ali



More information about the Digitalmars-d-learn mailing list