Transient ranges
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 30 05:20:25 PDT 2016
On 5/29/16 2:27 PM, default0 wrote:
> On Sunday, 29 May 2016 at 18:09:29 UTC, Steven Schveighoffer wrote:
>> On 5/29/16 1:45 PM, 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
>>> }));
>>
>> obviously, this is better as a simple && statement between the three
>> requirements :) When I started writing, I thought I'd have to write
>> some runtime code.
>>
>
> Would that make a range of polymorphic objects transient?
Of course! If it's mutable (or marked const), it can change from call to
call.
-Steve
More information about the Digitalmars-d
mailing list