enumap

Construct an Enumap from a sequence of key/value pairs.

Any values not specified default to V.init.

@nogc
enumap
(
T...
)
()
if (
T.length >= 2 &&
T.length % 2 == 0
)

Examples

with (Element) {
  auto elements = enumap(air, 1, earth, 2, water, 3);

  assert(elements[air]   == 1);
  assert(elements[earth] == 2);
  assert(elements[water] == 3);
  assert(elements[fire]  == 0); // unspecified values default to V.init
}

Meta