Metaprog can be abstruse
user1234
user1234 at 12.de
Mon Jul 4 10:37:14 UTC 2022
On Monday, 4 July 2022 at 10:29:24 UTC, bauss wrote:
> On Monday, 4 July 2022 at 08:24:01 UTC, user1234 wrote:
>> [...]
>
> If you don't like the iota version then you can just do this:
>
> (Modified version of yours.)
>
> ```d
> auto genDecimalRanks()
> {
> import std.conv;
>
> auto r = 1;
> int[] result = [];
>
> foreach (i; 1 .. 11)
> {
> result ~= r;
> r *= 10;
> }
>
> return result;
> }
>
> /// like
> [1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000]
> static immutable decimalRanks = genDecimalRanks();
> ```
>
> Everything at compile-time doesn't have to be strings and mixin
> :)
>
> static and enum will trigger ctfe.
still the same problems as the initial version (even if yes I
know it's absurd code)
More information about the Digitalmars-d
mailing list