printf() metaprogramming challenge

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Fri May 24 00:41:31 UTC 2019


On 5/23/19 6:58 PM, Yuxuan Shui wrote:
> On Thursday, 23 May 2019 at 19:33:15 UTC, Walter Bright wrote:
>> [snip]
>>
>> I completely failed at that. I suspect the language has a deficiency 
>> in manipulating expression tuples.
>>
>>
> 
> What a coincidence, I had this exact problem today as well. It seems 
> currently the only way to do this is either with mixins, or using tuple.
> 
> Assuming you already have all of the arguments in a tuple:
> 
>      auto args = tuple(...);
> 
> And args[x] is a string, you can do this:
> 
>      auto args_prime = tuple(args[0..x], args[x].length, args[x].ptr, 
> args[x..$]);
> 
> You then need to do some template magic to expand all such arguments... 
> Using mixin is probably better.

Did you try .expand with the tuple?



More information about the Digitalmars-d mailing list