MutexedAA.require

Returns the value for the key key, inserting value lazily if it is not present.

struct MutexedAA(AA : V[K], V, K)
require
(
K key
,
lazy V value
)

Parameters

key K

Key.

value V

Lazy value.

Return Value

Type: auto

The value for the key key, or value if there was no value there.

Examples

MutexedAA!(string[int]) aa;
aa.setup();  // important!

assert(!aa.has(42));
string hello = aa.require(42, "hello");
assert(hello == "hello");
assert(aa[42] == "hello");