Cast to original type each argument in template pack
Andrey
saasecondbox at yandex.ru
Tue Aug 21 08:08:58 UTC 2018
Hello,
I have a function:
> string format(string pattern, T...)(T value)
>{
> auto writer = appender!string();
>
> writer.formattedWrite!pattern(convertToUnderlyingType(value));
> //Tuple!T(value).expand.to!(OriginalType!T)
>
> return writer.data;
>}
The "value" in this function can be any type including "enum".
And if it is a "enum" I want to print it's contents not name.
So what I need - check if current argument in template pack is
enum then convert it in original type. If current argument isn't
enum - leave it as is. In my example I showed it with imaginary
function "convertToUnderlyingType".
How to implement it in D?
More information about the Digitalmars-d-learn
mailing list