Getting a range over a const Container

Matthias Walter xammy at xammy.info
Wed Jul 18 23:10:41 PDT 2012


On 07/19/2012 06:44 AM, Jonathan M Davis wrote:
> On Thursday, July 19, 2012 04:39:26 Francisco Soulignac wrote:
>> So, my question is how can I (correctly) traverse a const SList,
>> const DList, etc?
> 
> Right now? I'm pretty sure that that's impossible. Hopefully that will change, 
> but getting const and ranges to work together can be rather difficult, and 
> std.container needs more work in that regard.

Well it doesn't work yet. But in principle it could since we can always
copy a const pointer to a non-const one to const data:

Node* actual; // but 'this' is const and hence the type is const(Node*)

const(Node)* i_will_traverse = actual;

Best regards,

Matthias


More information about the Digitalmars-d-learn mailing list