RAII pointers
Moritz Maxeiner via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 3 14:39:54 PDT 2017
On Saturday, 3 June 2017 at 21:16:08 UTC, Stanislav Blinov wrote:
> On Saturday, 3 June 2017 at 20:53:05 UTC, Moritz Maxeiner wrote:
>>
>> Quite, but if you backtrack to my initial statement, it was
>> about ptr not being/becoming null (implicitly) in the first
>> place, which *might* allow you to skip the check (if you don't
>> set it to null via external means, such as memcpy, move, etc).
>
> It's only true as long as you have full control of the source.
> Once you're using libraries and generic code, it's possible
> that it's out of your hands:
It's always true, because I explicitly wrote *might*, not *will*,
to indicate that it depends on your use case. Your example is a
common use case where you can't skip the check.
More information about the Digitalmars-d-learn
mailing list