On Wednesday, 29 March 2023 at 16:44:31 UTC, Ali Çehreli wrote:
On 3/29/23 09:27, Salih Dincer wrote:

> In this way,
> it could also be used directly with slices. For example:

> auto put(R)(R[] range, R[] source)
>    => putImpl(range, source);

That's for rvalues.

> auto put(R)(ref R[] range, R[] source)
>    => putImpl(range, source);

That's for lvalues.

If you are proposing keeping the current ref-taking Phobos put() as well, then the following call would be ambiguous:

  slice.put([2]);  // Compilation ERROR

As far as I understand, you're saying that we cannot overload on `ref`. But we can. Salih's code demonstrates just that.

void f(ref int x) {}
void f(int x) {}
void main() { int x; f(x); f(42); } /* no errors */
  • 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
                • ... Paul Backus via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Paul Backus via Digitalmars-d-learn

Reply via email to