Transient ranges

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon May 30 06:31:58 PDT 2016


On 5/29/16 11:46 PM, Alex Parrill wrote:
> On Sunday, 29 May 2016 at 17:45:00 UTC, Steven Schveighoffer wrote:
>> On 5/27/16 7:42 PM, Seb wrote:
>>
>>> So what about the convention to explicitely declare a `.transient` enum
>>> member on a range, if the front element value can change?
>>
>> enum isTransient(R) = is(typeof(() {
>>    static assert(isInputRange!R);
>>    static assert(hasIndirections(ElementType!R));
>>    static assert(!allIndrectionsImmutable!(ElementType!R)); // need to
>> write this
>> }));
>>
>
> allIndrectionsImmutable could probably just be is(T : immutable) (ie
> implicitly convertible to immutable). Value types without (or with
> immutable only) indirections should be convertible to immutable, since
> the value is being copied.
>

Yes, I think that is correct. Thanks!

-Steve


More information about the Digitalmars-d mailing list