isRefCountedPayloadEnabled

Template to determine if hook defines that the Expected storage should use refcounted state storage.

If this is enabled, payload is mallocated on the heap and dealocated with the destruction of last $(Expected) instance.

See hasOnUnchecked handler, which can be used in combination with refcounted payload to enforce that the result is checked.

@safe
template isRefCountedPayloadEnabled (
Hook
) {
enum isRefCountedPayloadEnabled;
enum isRefCountedPayloadEnabled;
}

Examples

1 struct Foo {}
2 struct Bar {
3     static immutable bool enableCopyConstructor = false;
4     static immutable bool enableRefCountedPayload = true;
5 }
6 struct Hook { static immutable bool enableRefCountedPayload = true; }
7 static assert(!isRefCountedPayloadEnabled!Foo);
8 static assert(!__traits(compiles, isRefCountedPayloadEnabled!Bar));
9 static assert(isRefCountedPayloadEnabled!Hook);

Meta