wth!! ctfe cannot format floating point at compile time?
Stefan Koch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 14 01:46:27 PDT 2017
On Monday, 14 August 2017 at 04:29:17 UTC, Johnson wrote:
>> ```
>> auto valueToString(alias v)(){return v.stringof;}
>> enum a = valueToString!(0.75);
>> static assert(a == "0.75");
>> ```
> Thanks! You'd think that to would do this internally
> automatically ;/
It only works on literals.
valueToString!(a) will give you a;
More information about the Digitalmars-d-learn
mailing list