C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A non-owning but self zeroing smart pointer for single ownership

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sun, 16 Feb 2025 14:52:50 +0100
The described use case would be the following, right? 1. an object is allocated on the heap pointed to by p1 2. a function f is called copying (with arguments) the pointer to p2 3. during the run of the function f, f calls some other code; there p1 is freed (ideally p2 is also set to nullptr) 4. the function f tests p2 for nullptr, if == 0, skip 5 5. f dereferences p2 one or multiple times The solution described would work, if step 3 does not happen between the test in 4 and the dereferencing in 5

Received on 2025-02-16 13:57:05