StringOf

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

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>"
  1. template StringOf(alias U, string sep = ", ", string beg = "!(", string end = ")")
  2. string StringOf()
    string
    StringOf
    (
    T
    string sep = ", "
    string beg = "!("
    string end = ")"
    )
    ()
    if (
    is(TemplateOf!T == void)
    )

Parameters

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

Examples

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");

See Also

Meta