I think I've already recommended once to introduce a template such as:

```D
/** Return Target with qualifiers set to those of Source. */
template CopyQualifier(Source, Target)
{
         static if (is(Source U == shared(const U))) alias CopyQualifier = shared(const Target);
    else static if (is(Source U ==    immutable U )) alias CopyQualifier =    immutable(Target);
    else static if (is(Source U ==       shared U )) alias CopyQualifier =       shared(Target);
    else static if (is(Source U ==        const U )) alias CopyQualifier =        const(Target);
    else                                             alias CopyQualifier =              Target;
}
```

Then it would be used at call site via:

```D
return cast(CopyQualifier!(T, S))(source)");
```

If anything you could let it be private in this module until we move it to `std.traits`, I recommend it over the mixin approach.