On 3/29/23 04:48, Dennis wrote:
> On Wednesday, 29 March 2023 at 11:10:42 UTC, Salih Dincer wrote:
>> Why does my `put` work but the Phobos `put` doesn't work with a slice?
>
> Your `put` doesn't take `range` by `ref`, so it allows you to pass an
> rvalue. Consequently, it doesn't advance the range from the callers
> perspective.

And that 'ref' is necessary because not every OutputRange can be sliced for further calls to put(). Salih does not have that problem because he is working with slices, which are (usually) trivially slicable for the next portion to be passed to put().

On the other hand, Phobos's put() works with any OutputRange so it has to take a 'ref' to advance to know where it is left off. This behavior makes its use with slices weird but sometimes such is life. :)

Ali

  • The Phobos Put Salih Dincer via Digitalmars-d-learn
    • Re: The Phobos Put Dennis via Digitalmars-d-learn
      • Re: The Phobos Put Ali Çehreli via Digitalmars-d-learn
        • Re: The Phobos P... Salih Dincer via Digitalmars-d-learn
          • Re: The Phob... Ali Çehreli via Digitalmars-d-learn
            • Re: The... ag0aep6g via Digitalmars-d-learn
              • Re:... Ali Çehreli via Digitalmars-d-learn
                • ... ag0aep6g via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn

Reply via email to