Detecting ElementType of OutputRange

Stanislav Blinov stanislav.blinov at
Sat Feb 26 12:39:51 UTC 2022

On Saturday, 26 February 2022 at 12:26:21 UTC, Vijay Nayar wrote:
> On Saturday, 26 February 2022 at 11:44:35 UTC, Stanislav Blinov 
> wrote:
> This method requires the caller to explicitly declare the 
> output range element type, which I was hoping to have to avoid, 
> if it can be detected using reasonable assumptions.

Considering that `put` is quite typically implemented as a 
template, I don't think that would be possible in general.

The question is, do you really need that? Your 
`BufferedOutputRange` can test the underlying range using 
`isOutputRange` in its own implementation of `put`, where the 
type of element is known, i.e. to test whether it can bulk-write 
a slice (or a range of) elements or has to make per-element calls 
to `put`.

More information about the Digitalmars-d-learn mailing list