ChainImpl save method

Andrej Mitrovic none at none.none
Wed Dec 29 12:26:25 PST 2010


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.

Btw, I'm having a kick-ass time understanding Phobos as of lately. It only took me a couple of months but I am slowly grokking templates, even though I've *never* used templates before I tried D. 


More information about the Digitalmars-d-learn mailing list