oc

Allows you to call dot operator on a nullable type or an optional.

If there is no value inside, or it is null, dispatching will still work but will produce a series of no-ops.

Works with std.typecons.Nullable

If you try and call a manifest constant or static data on T then whether the manifest or static immutable data is called depends on if the instance is valid.

  1. auto oc(T value)
  2. auto oc(Optional!T value)
    oc
    (
    T
    )
    (
    auto ref Optional!T value
    )
  3. auto oc(Nullable!T value)

Return Value

Type: auto

A type aliased to an Optional of whatever T.blah would've returned.

struct A {
    struct Inner {
        int g() { return 7; }
    }
    Inner inner() { return Inner(); }
    int f() { return 4; }
}
auto a = some(A());
auto b = no!A;
auto c = no!(A*);
oc(a).inner.g; // calls inner and calls g
oc(b).inner.g; // no op.
oc(c).inner.g; // no op.

Meta