Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.qualifier

Const and Immutable qualifiers helpers for Mir Type System.
License:
Authors:
Ilya Yaroshenko
template LightScopeOf(T)
template LightConstOf(T)

template LightImmutableOf(T)
ref auto lightScope(T)(auto return ref T v)
if (!is(T : P*, P) && __traits(hasMember, T, "lightScope"));

ref auto lightScope(T)(auto return ref T v)
if (is(T : P*, P) || !__traits(hasMember, T, "lightScope"));
Tries to strip a reference counting handles from the value. This funciton should be used only when the result never skips the current scope.
This function is used by some algorithms to optimise work with reference counted types.
auto lightImmutable(T)(auto immutable ref T v)
if (!is(T : P*, P) && __traits(hasMember, immutable(T), "lightImmutable"));

T lightImmutable(T)(auto immutable ref T e)
if (!isDynamicArray!T && isImplicitlyConvertible!(immutable(T), T) && !__traits(hasMember, immutable(T), "lightImmutable"));

auto lightImmutable(T)(immutable(T)[] e);

auto lightImmutable(T)(immutable(T)* e);
auto lightConst(T)(auto const ref T v)
if (!is(T : P*, P) && __traits(hasMember, const(T), "lightConst"));

auto lightConst(T)(auto immutable ref T v)
if (!is(T : P*, P) && __traits(hasMember, immutable(T), "lightConst"));

T lightConst(T)(auto const ref T e)
if (!isDynamicArray!T && isImplicitlyConvertible!(const(T), T) && !__traits(hasMember, const(T), "lightConst"));

T lightConst(T)(auto immutable ref T e)
if (!isDynamicArray!T && isImplicitlyConvertible!(immutable(T), T) && !__traits(hasMember, immutable(T), "lightConst"));

auto lightConst(T)(const(T)[] e);

auto lightConst(T)(immutable(T)[] e);

auto lightConst(T)(const(T)* e);

auto lightConst(T)(immutable(T)* e);
@trusted auto trustedImmutable(T)(auto const ref T e);