Proof of concept for v2 - NO duplication, NO `static if` hell, NO difficulty with interoperability
Paul Backus
snarwin at gmail.com
Mon Nov 1 18:44:17 UTC 2021
On Monday, 1 November 2021 at 15:39:46 UTC, Andrei Alexandrescu
wrote:
> On 11/1/21 10:09 AM, Ogi wrote:
>> On Sunday, 31 October 2021 at 01:59:38 UTC, Andrei
>> Alexandrescu wrote:
>>> https://github.com/dlang/phobos/pull/8309
>>>
>>> Destroy!
>>
>> Good stuff.
>>
>> Notably absent are `std.range.interfaces`. What are we going
>> to do about them?
>
> I don't think they need particular attention - either publish
> them as they are, change them, or give up on them altogether (I
> believe allowing ref-type ranges was a mistake).
Easiest thing would be to wrap the class reference in a struct
that calls `save` in its copy constructor, but does not expose a
`save` method to its users:
import std.range.interfaces;
struct ForwardRangeObject(E)
{
private ForwardRange!E payload;
@property auto ref front() { return payload.front; }
// etc.
this(ref inout typeof(this) other) inout
{
payload = other.payload.save;
}
}
More information about the Digitalmars-d
mailing list