Returning range of inout objects from inout method
Steven Schveighoffer
schveiguy at gmail.com
Sat Jul 25 20:07:00 UTC 2020
On 7/25/20 3:16 PM, FreeSlave wrote:
> On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote:
>>
>> The only way to do this without code duplication (but with generated
>> code duplication) is to template the byAction function on the type of
>> `this`:
>>
>> auto byAction(this This)() { /* same implementation */ }
>>
>> Note that this ONLY works if your base range type is an array. If you
>> have a custom range type, you need to parameterize that based on the
>> constness of `This`.
>>
>
> Thanks. I thought this template is useful only in inheritance.
> Is constness of member function inferred automatically in this case?
In this case, yes. I don't know actually if this is documented.
-Steve
More information about the Digitalmars-d-learn
mailing list