One possible solution:

Another idea is to make "byPair" and "pairs" templates that by default return 2-structs and use a Tuple on request (so you have to import Phobos Tuple if you want them, so byPair doesn't depend on Phobos and you can put in druntime):

int[string] aa;
assert(aa.byPair.array == aa.pairs);

byPair yields something like:
struct Pair { string key; value int; }

Now this yields tuples:
assert(aa.byPair!Tuple.array == aa.pairs!Tuple);

Bye,
bearophile

Reply via email to