Strings concatenated at compile time?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 1 05:23:47 PDT 2014


Jonathan M Davis:

> If you want it to be guaranteed, you'd do something like
>
> template foo(string s)
> {
>     enum foo = s ~ " betty";
> }

A more general solution is to wrap the concatenation with a call 
to:

alias ctEval(alias expr) = expr;

Use:

string bar() { return ctEval!(s ~ " betty"); }

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list