Function oc

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

auto oc(T) (
  auto ref T value
)
if (from.bolts.traits.isNullTestable!T);

auto oc(T) (
  auto ref Optional!T value
);

auto oc(T) (
  auto ref Nullable!T value
);

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.

Returns

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.