On Wed, 29 Dec 2010 15:26:25 -0500, Andrej Mitrovic <[email protected]> wrote:

I'm having trouble understanding this code in std.range.chainImpl:

        @property ChainImpl save()
        {
            auto result = ChainImpl();
            foreach (i, Unused; R)
            {
                result._input[i] = _input[i].save;
            }
            return result;
        }

Specifically, line 1559 which is:
auto result = ChainImpl();

Let me see if I got my hunch right:

Is this simply instantiating another implementation of ChainImpl with the same arguments? e.g. inside an already instantiated template with ChainImpl(Range1, Range2), would ChainImpl() simply instantiate another ChainImpl template with the same compile-time arguments? Of course, it wouldn't copy any runtime values since this is all done at compile-time and they don't exist yet.

Yes. Inside a template, the name of the template is synonymous with the template instance being instantiated.

So for example:

struct S(T)
{
   void foo(){ S s; // this is of type S!T
   }
}

-Steve

Reply via email to