InoutOf

Applies inout to the given type.

This is primarily useful in conjunction with templates that take a template predicate (such as many of the templates in phobos.sys.meta), since while in most cases, you can simply do inout T or inout(T) to make T inout, with something like phobos.sys.meta.Map, you need to pass a template to be applied.

alias InoutOf(T) = T

Examples

static assert(is(InoutOf!int == inout int));
static assert(is(InoutOf!(const int) == inout const int));
static assert(is(InoutOf!(inout int) == inout int));
static assert(is(InoutOf!(shared int) == inout shared int));

// Note that inout has no effect on immutable.
static assert(is(InoutOf!(immutable int) == immutable int));

import phobos.sys.meta : AliasSeq, Map;

alias Types = AliasSeq!(int, long,
                        bool*, ubyte[],
                        string, immutable(string));
alias WithInout = Map!(InoutOf, Types);
static assert(is(WithInout ==
                 AliasSeq!(inout int, inout long,
                           inout(bool*), inout(ubyte[]),
                           inout(string), immutable(string))));

See Also

Meta