Template for going from Array --> list of args
Bill Baxter
dnewsgroup at billbaxter.com
Wed Jan 31 11:43:18 PST 2007
Don Clugston wrote:
> Frits van Bommel wrote:
>> Bill Baxter wrote:
>>> Kirk McDonald wrote:
>>>> ParameterTypeTuple!(typeof(&fn)) t;
>>>
>>> Whoa, didn't realize you could make a variable out of a type tuple.
>>> Or if I did know it once, I completely forgot it.
>>>
>>>> foreach (i, e; t) {
>>>> t[i] = array[i];
>>>> }
>>>
>>> I guess this squashes any hope of the thing getting inlined... :-(
>>
>> Are you sure? 'foreach' with a tuple as aggregate is automatically
>> unrolled. Sort of a "static foreach", really. So it's not actually a
>> loop. In fact, the index is a compile-time constant.
>> I'm not sure how the compiler handles this, but I suspect the
>> optimizer may not even know it used to be any kind of loop at all...
>
> I'm almost certain you're right. If inside the loop, you insert asm
> statements, they are placed after each other, with no indication that
> the loop ever existed. (Makes it possible to write a compile-time
> compiler that writes directly to asm code...).
Ok. All's the better then. Thanks to the three of ya.
--bb
More information about the Digitalmars-d-learn
mailing list