Template to retrieve compile-time enum member from run-time enum member?

Alex sascha.orlov at gmail.com
Fri Apr 27 14:33:36 UTC 2018


On Friday, 27 April 2018 at 13:43:47 UTC, Timoses wrote:
>
> `instantiateWith` gets called in three variations (menum.A, 
> menum.B and menum.C). This causes instantiateWith to return 
> TempStruct for each case of Temp...
>
> However, I was under the impression that a templated function 
> will exist multiple (in this case 3) times, so the return type 
> should be allowed to be different?!

I think, because the enum value is a runtime parameter for 
instantiateWith, only a single variation of it exists. And this 
cannot have different return types.
So... "alias Fn" and "T" stay the same. The value of x varies.

https://run.dlang.io/is/jX4Ybh
states the same.


More information about the Digitalmars-d-learn mailing list