import std.typecons : tuple; import std.algorithm : map; immutable elements = enumap(Element.water, 4, Element.air, 3); auto pairs = elements.byKeyValue.map!(pair => tuple(pair[0], pair[1] + 1)); foreach(key, value ; pairs) { assert( key == Element.water && value == 5 || key == Element.air && value == 4 || value == 1); }
Return a range of (EnumMember, value) pairs.
Note that byKeyValue does _not_ support modifying the underlying values by reference. For that, you should just use foreach directly (see opApply).