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

Timoses timosesu at gmail.com
Sat Apr 28 20:04:15 UTC 2018


On Friday, 27 April 2018 at 14:33:36 UTC, Alex wrote:
> 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.

Ah yes, thanks. I see it now.


More information about the Digitalmars-d-learn mailing list