RAII pointers

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 3 14:46:45 PDT 2017


On Saturday, 3 June 2017 at 21:39:54 UTC, Moritz Maxeiner wrote:
> 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.

Programmers and their tight-binding logic...

- Honey, please buy a loaf of bread. If there are eggs, buy a 
dozen.
...
- Hello, do you have eggs?
- Yes.
- Dozen loaves of bread, please.

;)


More information about the Digitalmars-d-learn mailing list