printf() metaprogramming challenge

Radu void at null.pt
Fri May 24 07:09:56 UTC 2019


On Friday, 24 May 2019 at 04:49:22 UTC, bpr wrote:
> On Thursday, 23 May 2019 at 19:33:15 UTC, Walter Bright wrote:
>> string formatString(string f, string[] A ...)
>> {
>>     string r;
>>     size_t i;
>>     size_t ai;
>>     while (i < f.length)
>>     {
>> 	if (f[i] != '%' || i + 1 == f.length)
>> 	{
>> 	    r ~= f[i];
>
>
> Are you sure this works for betterC? It's been a while for me, 
> but I think it won't, the string appends will stop it.
>
> Good job at getting unit tests and final switch in!
>
>> ----- End Of Das Code ----------

Indeed it doesn't work with -betterC flag. Easily testable on 
run.dlang.io

This probably would work if CTFE was supported when compiling 
with betterC.




More information about the Digitalmars-d mailing list