shared_ptr.hpp¶
Ludus Wiki · API overview · Browse API
File
Atomic shared ownership and weak observation of one domain-allocated object.
TryMakeShared<T> allocates one combined controller/object block through an AllocationDomain and writes SharedPtr<T>. Copies of that owner share the object; WeakPtr<T> observes it without keeping it alive and can promote back to a strong owner only while it is live. The final strong release destroys the exact object on the releasing thread; the final weak release (including the strong lifetime's implicit hold) frees the block through the original domain. The contract is specified in docs/architecture/smart-pointers.md ("Shared object and controller", "Controller state and reclamation", delivery slice 3).Thanks to the ISO C++ working draft's shared owner (https://eel.is/c++draft/util.smartptr.shared) and weak observer (https://eel.is/c++draft/util.smartptr.weak.obs) contracts, whose ownership and atomic weak-promotion semantics this narrows: there is no raw-pointer adoption, aliasing, array ownership or shared-from-this, and construction reports failure as an explicit status.
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp