4 ms·
> It's an invariant of the 'DirectorySearchResult' class that query is non-null, as the destructor deletes it without checking it for nullity. Deleting a null
by jemfinch 8y ago
> It's an invariant of the 'DirectorySearchResult' class that query is non-null, as the destructor deletes it without checking it for nullity.
Deleting a null pointer is a fully specified no-op in C++.
- lemmyg 8y agoThat's true. And I see the other example answers they have written do assume the pointer can be null, although the original class makes no indication of this. To make the question clearer they should have added a function on the original class that checks (or doesn't check) the pointer before dereferencing it, thereby clarifying whether query being null is valid or not.