Using double value in string template mixin

Dibyendu Majumdar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 26 04:12:26 PST 2016


On Friday, 26 February 2016 at 11:37:32 UTC, BBasile wrote:
> Erratum! Actually you can, example:
>
> import std.stdio;
>
> string foo(double a)()
> {
>     return "auto value = " ~ a.stringof ~ ";";
> }
>
> void main(string[] args)
> {
>     mixin(foo!0.1);
>     writeln(value); // 0.1
>     writeln(typeof(value).stringof); // double
> }
>
> So you have to use .stringof on the template argument.
> Sorry for the previous answer.

Thank you!



More information about the Digitalmars-d-learn mailing list