parameter pack to inputRange
Dicebot via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 9 07:00:14 PDT 2016
On Monday, 9 May 2016 at 12:36:00 UTC, Ali Çehreli wrote:
> On 05/09/2016 03:44 AM, Dicebot wrote:
>
> > Ali version generates a compile-time switch for index
>
> I think it's a run-time switch, generated by a compile-time
> foreach:
>
> E front() {
> final switch (index) { // <-- RUNTIME
> /* static */ foreach (i, arg; Args) { // <-- COMPILE
> TIME
> case i: // <-- RUNTIME
> return arg; // <-- RUNTIME
> }
> }
> }
>
> Quite confusing. :)
It becomes even more confusing if you keep in mind that it is a
final switch on an index range known at compile-time - which
means that as long as whole template can be inlined and actual
index is know at CT, compiler can eliminate all runtime indexing
checks and just replace it with matching literal/symbol.
More information about the Digitalmars-d-learn
mailing list