mutexedAA

Convenience function to create and setup a MutexedAA instance. Overload that inherits an original associative array, or optionally duplicates it. Infers the types to instantiate the MutexedAA with from the AA passed.

Note: The original associative array must be mutable.

  1. auto mutexedAA()
  2. auto mutexedAA(AA orig)
    mutexedAA
    (
    Flag!"dup" performDup = Yes.dup
    AA : V[K]
    V
    K
    )
    (
    AA orig
    )
    if (
    __traits(isAssociativeArray, AA)
    )

Parameters

performDup

Whether or not to dup the original associative array, or to inherit it by reference. Default is Yes.dup.

orig AA

Original associative array.

Return Value

Type: auto

A new MutexedAA instance, initialised with the passed original associative array.

Examples

auto orig = [ 1 : "one", 2 : "two", 3 : "three" ];
auto aa = mutexedAA(orig);
// no need to setup
assert(1 in aa);
{
    auto orig = [ 1 : "one", 2 : "two", 3 : "three" ];
    auto aa = mutexedAA(orig);
    aa[4] = "four";
    assert(aa.has(4));
    assert(4 !in orig);
}
{
    auto orig = [ 1 : "one", 2 : "two", 3 : "three" ];
    auto aa = mutexedAA!(No.dup)(orig);
    aa[4] = "four";
    assert(aa.has(4));
    assert(4 in orig);
}