Variable StringOf

Returns a stringof another template with it's real and non-mangled types

void StringOf(alias U, string sep = ", ", string beg = "!(", string end = ")") = text(tmpName, beg, SeparatedArgNames, end);


string StringOf(T, string sep = ", ", string beg = "!(", string end = ")")()
if (is(TemplateOf!T == void));

You may also customize the format in the case of templates:

struct S(T, U) {}
StringOf!(S!(int, int)).writeln; // "S!(int, int)"
StringOf!(S!(int, int), "...", "<", ">").writeln; // "S<int...int>"

Variable StringOf

Function StringOf

Parameters

NameDescription
T the type you want to stringize
sep in case of a template, what's the deperator between types
beg in case of a template, what token marks the beginnig of the template arguments
end in case of a template, what token marks the end of the template arguments

See Also

- https://forum.dlang.org/post/iodgpllgtcefcncoghri@forum.dlang.org

Example

template A(T...) {}
struct B {}
struct C {}
alias T = A!(A!(B, C));
assert(StringOf!T == "A!(A!(B, C))");

struct S(T) {}
assert(StringOf!(S!int) == "S!(int)");
assert(StringOf!(A!(A!(B, S!int))) == "A!(A!(B, S!(int)))");

assert(StringOf!int == "int");
assert(StringOf!3 == "3");

void f(int a, int b) {}
import std.algorithm: canFind;
assert(StringOf!(f).canFind("void(int a, int b)"));

assert(StringOf!void == "void");