Ambiguity issue with expanding and evaluating single template type parameter enums

data pulverizer data.pulverizer at gmail.com
Tue Dec 28 02:16:48 UTC 2021


On Tuesday, 28 December 2021 at 00:57:27 UTC, Paul Backus wrote:
>>>
>>> ```d
>>> enum instantiate(string type, string expr) = type ~ "(" ~ 
>>> expr ~ ")";
>>> pragma(msg, instantiate!("RVector!(SEXPTYPE.REALSXP)", "x"));
>>> ```
>>

One possibility is to generate a collection of compile time 
strings that denote the types and then to a comparison with the 
type something like `is(T == mixin(CString)`, where `CString = 
"RVector!(SEXPTYPE.REALSXP)"` to discover the correct string 
which I can then use to generate the code without having to use 
`T.stringof` anywhere in the code at all.



More information about the Digitalmars-d-learn mailing list