Template Struct Block
Defined in File block.h
Struct Documentation
-
template<typename T>
struct Block A contiguous range within one backing allocation.
owner keeps that allocation alive; head may point into it after a split. length counts T objects (bytes for void). Splitting produces ranges with the same owner without transferring storage. Range mutation requires caller synchronization and valid representable backing bounds. Compound registry/pool transitions use CE::Memory::BlockTransactions instead.
Public Types
Public Functions
-
OBlock split_exactly(std::size_t idx)
Split this range at an exact element/byte offset, retaining common backing ownership.
- Parameters:
idx – Positive offset strictly below length; null head or invalid offset returns nullopt unchanged.
- Returns:
Right remainder; this Block becomes the left range. No allocation bytes move, no T objects are constructed/destroyed, and no pool records are updated. Caller supplies valid representable backing bounds and excludes concurrent edits.
-
OBlock split_at(std::size_t idx)
Split typed ranges exactly, or seek a preferred aligned right tail for void-byte ranges.
- Parameters:
idx – Requested element/byte offset; the byte left range may absorb alignment padding.
- Returns:
Right alias or nullopt when no legal nonempty remainder exists. No backing storage/object lifetime or pool bookkeeping changes beyond this Block’s local length. Valid nonzero alignment/representable bounds and caller synchronization are prerequisites.
-
bool contains(void *p) const
Test a half-open address interval using length elements (bytes for void).
- Parameters:
p – Candidate address, compared numerically with this valid representable range.
- Returns:
Whether p lies at/after head and before its computed end. This does not prove a live T object, allocation validity, checkout status or thread safety. Caller ensures length*sizeof(T) and derived end are representable.
-
inline std::vector<spointer> vector(std::function<void(T*)> d)
Create separate shared_ptr control blocks for each element of a nonvoid range.
- Parameters:
d – Copied per-element final deleter responsible for constructed lifetime and retaining/releasing backing storage.
- Returns:
Independent element handles; they are not aliases of owner and this helper does not itself retain that owner. Requires addressable contiguous T storage for length elements and external lifetime/synchronization. No objects are constructed; allocation failure releases already made handles through their deleters.
-
OBlock split_exactly(std::size_t idx)