On Wednesday, 29 March 2023 at 20:50:04 UTC, Steven Schveighoffer wrote:
On 3/29/23 4:29 PM, ag0aep6g wrote:

But regardless of Salih's exact intent, the broader point is: a non-ref overload could be added to Phobos. And that would enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked about originally.

I think the idea of requiring ref output ranges is that you can then let the range keep track of its output state.

So why not copying the range to a static array? The error during compilation of the code is as follows:

onlineapp.d(6): Error: none of the overloads of template `std.algorithm.mutation.copy` are callable using argument types `!()(int[], int[8])`
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/mutation.d(367):        
Candidate is: `copy(SourceRange, TargetRange)(SourceRange source, TargetRange 
target)`
  with `SourceRange = int[],
       TargetRange = int[8]`
  must satisfy the following constraint:
`       isOutputRange!(TargetRange, ElementType!SourceRange)`

```d
import std.algorithm.mutation : copy;
void main()
{
  int[8] buf;
  auto dig = [1, 2, 3, 4];
  auto rem = dig.copy(buf);
  assert(rem.length == 4);
}

```

Looks like 'copy' has the same overload issue.

SDB@79

  • 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
                • ... Salih Dincer via Digitalmars-d-learn

Reply via email to