Make sure lifetime of helper structs is less than owning struct

Ali Çehreli acehreli at yahoo.com
Mon Nov 15 22:49:12 UTC 2021


On 11/15/21 2:33 PM, Imperatorn wrote:
> On Monday, 15 November 2021 at 22:27:24 UTC, Ali Çehreli wrote:
>> On 11/15/21 1:58 PM, WebFreak001 wrote:
>> > [...]
>> wrote:
>> >> [...]
>> wrote:
>> >> [...]
>> the use of
>> >>         [...]
>> variable `file`
>> > [...]
>> copying the
>> > [...]
>> a pointer.
>> I don't see how it solves the problem. Sebastiaan Koppe might have 
>> intended to allocate the object dynamically with 'new' as well?
>>
>> [...]
> 
> Are you compiling with preview=dip1000?

Trying with it produces an error when 'new' is not used:

Error: reference to local variable `file` assigned to non-scope 
parameter `p` calling deneme.ByChunk.opAssign

So, I either misunderstand or understand very well :) that a different 
way of lifetime management (like adding 'new') is needed there.

Ali



More information about the Digitalmars-d-learn mailing list