Lstr

式を埋め込み可能な文字列リテラルを構築します

Members

Functions

generate
string generate(string s)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

Lstr
enum string Lstr;
Undocumented in source.

Examples

{
    int a = 12, b = 13;

    assert(mixin(Lstr!"aaaa") == "aaaa");

    // %[ から %] までがDの任意の式を表す。
    assert(mixin(Lstr!`foo%[a+b%]bar%[a+10%]%[a%]`) == "foo25bar2212");
}

{
    int a = 12;
    string b = "3";
    auto t = tuple(a, b);
    string str = mixin(Lstr!`Element1 : %[t[0]%], Element2 : %[t[1]%]`);
    assert(str == `Element1 : 12, Element2 : 3`);
}

{
    int a = 12;
    assert(mixin(Lstr!`foo%[a%]`) == "foo12");
    assert(mixin(Lstr!`foo%[a%`) == `foo%[a%`);
    assert(mixin(Lstr!`foo%[a`) == `foo%[a`);
    assert(mixin(Lstr!`foo%[%]`) == `foo`);
    assert(mixin(Lstr!`foo%[`) == `foo%[`);
    assert(mixin(Lstr!`foo%`) == `foo%`);
}

Meta