Associative Ranges implementation questions

Freddy via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 8 18:41:35 PDT 2014


On Saturday, 9 August 2014 at 01:34:38 UTC, Freddy wrote:
> As of now Associative Ranges are defined as:
> ----
> static assert(isInputRange!R);
> R r=void;
> auto v=r.front;//r is an input range
> static assert(isInputRange!(typeof(r.byKey)));
> auto k=r.byKey.front;//byKey is an input range
> static assert(is(typeof(v) ==typeof(r[k]) ));//opIndex of k
> static assert(is(typeof(v) ==typeof(*(k in r))
> ));//opBinearyRight!"in" of k
> ----
> Should associative ranges be a forward range instead of input
> range?
> Should associative ranges provide an opApply for keys and
> elements(note: this conflicts with range's default 
> foreach(size_t
> counter,E element) so we will have to redesign the interface)?
> Which functions from std.range, std.algorithm, etc; should have
> special cases for associatve ranges(map, chain,etc)?
Opps i forgot to post a link to my phobos fork:
https://github.com/Superstar64/phobos/tree/associative_ranges


More information about the Digitalmars-d mailing list