static assert(is(ConstOf!int == const int)); static assert(is(ConstOf!(const int) == const int)); static assert(is(ConstOf!(inout int) == inout const int)); static assert(is(ConstOf!(shared int) == const shared int)); // Note that const has no effect on immutable. static assert(is(ConstOf!(immutable int) == immutable int)); import phobos.sys.meta : AliasSeq, Map; alias Types = AliasSeq!(int, long, bool*, ubyte[], string, immutable(string)); alias WithConst = Map!(ConstOf, Types); static assert(is(WithConst == AliasSeq!(const int, const long, const(bool*), const(ubyte[]), const(string), immutable(string))));
Applies const 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 const T or const(T) to make T const, with something like phobos.sys.meta.Map, you need to pass a template to be applied.