Can't print enum values

aliak something at something.com
Fri Aug 31 12:21:48 UTC 2018


On Friday, 31 August 2018 at 10:51:51 UTC, Andrey wrote:
> On Thursday, 30 August 2018 at 12:04:26 UTC, vit wrote:
>> On Thursday, 30 August 2018 at 11:34:36 UTC, Andrey wrote:
>>> On Thursday, 30 August 2018 at 11:09:40 UTC, vit wrote:
>>>> [...]
>>>
>>> I want to create a reusable template for this purpose.
>>> Why I can't use "staticMap" so that compiler it self would do 
>>> this:
>>>>[...]
>>> Just wrap some some symbol "args" with some expression at 
>>> compile time.
>>>
>>> It is the same as in C++:
>>>>[...]
>>
>> D doesn't have expanding like C++
>>
>> Unfortunately D has only simple automatic expading.
>
> So how can one implement a reusable template "apply some 
> function to each argument in template parameter pack" in D?

auto ToUnderlyingType(alias a)() {
     return cast(OriginalType!(typeof(a)))a;
}

void print(T...)(T args) {
     writeln(staticMap!(ToUnderlyingType, args));
}


More information about the Digitalmars-d-learn mailing list