|
jam 0.0.1
A compacting generational garbage collector for C++26
|
A four-byte weak heap field; tracing updates its slot without retaining its target.Construct from a ptr or root. Collection clears the field when its target is unclaimed; minor collection leaves old targets alone. Use lock() to retain a target across collection. There is no control block or external registration: stack copies expire at collection just like ptr, even if the target survives. The field must be listed in its owner's manifest or trace hook. More...
Public Types | |
| using | element_type = T |
| Target record type; may be incomplete. | |
| using | offset = std::uint32_t |
| The same generation-tagged cell index used by ptr. | |
Public Member Functions | |
| constexpr | weak_ptr () noexcept=default |
| Construct an empty weak pointer. | |
| constexpr | weak_ptr (std::same_as< std::nullptr_t > auto) noexcept |
| Implicitly construct an empty weak pointer. | |
| constexpr | weak_ptr (ptr< T > const &value) noexcept |
| Observe a strong pointer without retaining its target. | |
| weak_ptr (root< T > const &value) noexcept | |
| Observe a registered root without retaining its target. | |
|
template<class U> requires (!std::same_as<T, U>) && std::convertible_to<ptr<U>, ptr<T>> | |
| constexpr | weak_ptr (ptr< U > const &value) noexcept |
| Observe a derived pointer through its supported base conversion. | |
| constexpr | weak_ptr (weak_ptr const &other) noexcept |
| Copy and register an old-to-young weak slot when necessary. | |
| constexpr | weak_ptr (weak_ptr &&other) noexcept |
| Transfer the weak pointer, leaving the source empty. | |
| constexpr weak_ptr & | operator= (weak_ptr &&other) noexcept |
| Transfer the weak pointer; self-move leaves it unchanged. | |
| constexpr | ~weak_ptr () noexcept |
| Remove a dying old slot from the remembered set. | |
| constexpr void | swap (weak_ptr &other) noexcept |
| Exchange targets while preserving each slot's weak barrier. | |
| constexpr weak_ptr & | unsafe_assign (offset bits) noexcept |
| Assign encoded bits without registration; the caller owns the barrier. | |
| constexpr weak_ptr & | unsafe_assign (weak_ptr const &other) noexcept |
| Assign without registration; the caller must remember old-to-young slots. | |
| constexpr offset | get () const noexcept |
| Read the encoded offset; an external copy expires on collection. | |
| constexpr bool | is_young () const noexcept |
| Whether this field targets the young generation. | |
| constexpr bool | expired () const noexcept |
| Whether null or cleared by collection; this does not initiate collection. | |
| root< T > | lock () const noexcept |
| Retain the current target as a strong root, or return an empty root. | |
| constexpr auto | operator<=> (weak_ptr const &) const noexcept=default |
| Compare current encoded offsets within one heap. | |
Friends | |
| constexpr void | swap (weak_ptr &a, weak_ptr &b) noexcept |
| Exchange weak pointers through ADL. | |
A four-byte weak heap field; tracing updates its slot without retaining its target.
Construct from a ptr or root. Collection clears the field when its target is unclaimed; minor collection leaves old targets alone. Use lock() to retain a target across collection. There is no control block or external registration: stack copies expire at collection just like ptr, even if the target survives. The field must be listed in its owner's manifest or trace hook.
|
inlinenodiscardnoexcept |