Introduce observable_sealed_ptr
, improve memory footprint in C++17 #2
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Main changes:
observable_unique_ptr
will now optimize memory usage for empty (stateless) deleters for all versions of C++, not just C++20.observable_unique_ptr
has been split intoobservable_unique_ptr
andobservable_sealed_ptr
. The former preserves the original API, except that allocation optimisation inmake_observable_unique()
has been disabled (it prevents writing a saferelease()
function). The latter has the same API except it is missingvoid reset(T*)
andT* release()
; once a raw pointer is acquired, it is "sealed" inside the smart pointer. This enables the allocation optimisation inmake_observable_sealed()
. You can choose between the two pointers depending on your needs:release()
? useobservable_unique_ptr
.release()
? useobservable_sealed_ptr
(reset(T*)
can be achieved by assignment).Additional changes:
observer_ptr
not assignable fromobservable_unique_ptr
with a custom deleter, and not assignable from other observer pointer of same type.observable_unique_ptr
with aT*
equal tonullptr
(but not directlynullptr
).release()
from amake_observable_unique()
pointer leaving observer pointer with a dangling control block when the user deletes the released pointer.