Creating ranges over mutable, const, or immutable data structures.

w0rp via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 24 11:19:00 PDT 2014


On Saturday, 24 May 2014 at 18:01:43 UTC, Ali Çehreli wrote:
> On 05/24/2014 10:02 AM, w0rp wrote:
>
> > I have been writing my own hashmap which can provide forward
> ranges
> > usable in @safe pure nothrow functions, because it's going to
> be useful
> > for creating graph data structures with the same. I came to
> writing my
> > ranges and I figured out how to do everything right for just
> mutable
> > hashmaps, but I have no idea how to manage the tail-const
> nature of
> > ranges in a variety of combinations. I figured out that I
> need to
> > satisfy the following constraints.
> >
> > Create a mutable KeyRange over a map which forwards on the
> right
> > constness for the key type, so the following must be true.
> >
> > HashMap!(K, V).keys.front -> K
> > const(HashMap!(K, V)).keys.front -> const(K)
> > immutable(HashMap!(K, V)).keys.front -> immutable(K)
> >
> > I have encounted some difficulty in trying to write a range
> which does
> > this.
>
> How timely! :) Jonathan Crapuchettes talked about facing the 
> same issue in his talk at DConf. Perhaps he will post his 
> WrapMutability template here or you can wait for his talk on 
> YouTube.
>
> Ali

I thought someone would say something like that! I'll wait for 
the talk I suppose.


More information about the Digitalmars-d-learn mailing list