Parma Polyhedra Library requirements
C++ box textual interfaces and memory accounting
PPL-SPEC-000969
1. Human-readable box presentation PPL-SPEC-000969

Insertion shall write false for an empty box and true for a universe box. Otherwise, it shall visit every ambient coordinate in increasing index order and write the active variable name, the literal separator " in ", and that coordinate's interval presentation. Consecutive coordinates shall be separated by ", ". Unrestricted factors of a non-universe product shall also be shown. Zero-dimensional empty and universe shall retain their respective words. Successful insertion shall return the supplied stream reference without adding a newline or explicitly flushing it.

Variable names shall follow the active formatter and its live-callback prerequisites in 🔗 7. Active Variable formatter and initialized thread state and 🔗 8. Variable names, formatter dispatch and output failures. Interval presentation shall follow 🔗 2. Readable interval presentation and output delivery, including stream formatting and locale. The display shall not encode a separate ambient-dimension header. print() shall deliver the same display to the current std::cerr without appending a newline.

The represented box value shall remain unchanged; logically const emptiness/universe queries may refresh status. Stream failures shall retain the supplied stream's state and exception-mask behavior. Exceptions escaping the selected formatter, endpoint or stream operations shall propagate with partial output retained; their internal stream handling shall follow the applicable exception mask. Rendering callbacks shall not invalidate or mutate the box or coordinate storage being visited.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

PPL-SPEC-000970
2. Reloadable box record export PPL-SPEC-000970

Under compatible machine-output formatting and endpoint serialization prerequisites, ascii_dump(s) shall emit the box status record, the label space_dim, the ambient dimension and a newline, followed by exactly one serialized interval record per coordinate in increasing index order. The status protocol shall follow 🔗 5. Status ASCII loading and partial rejection state; interval records shall follow 🔗 4. Reloadable interval metadata and endpoint export. The record shall retain enough information to reload the same ambient dimension and mathematical Cartesian value with 🔗 3. Compatible box record loading and failure state.

For a box whose status already certifies emptiness, endpoint storage may be inactive. Export shall emit a valid canonical universe interval for each such coordinate without interpreting inactive endpoint payloads. The certified empty status shall preserve the empty Cartesian meaning independently of those replacement records. For other valid status states, coordinate export shall retain the interval serialization's metadata and inactive-payload rules. Export shall preserve the source mathematical value and shall not require first querying its emptiness.

ascii_dump() shall deliver the same record to the current std::cerr. Output shall require sufficient stream resources, compatible numeric formatting/locale and the selected endpoint codec's prerequisites. Stream/endpoint/resource failures shall retain their own state and exception behavior, with no output rollback. The record shall not imply cross-version or different-policy format compatibility.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

PPL-SPEC-000971
3. Compatible box record loading and failure state PPL-SPEC-000971

For a complete valid record produced under 🔗 2. Reloadable box record export with compatible status, interval policy, endpoint arithmetic, dimension limits, numeric formatting and locale, ascii_load(s) shall return true and replace the destination by the recorded ambient dimension and mathematical Cartesian value. It shall consume one box record, permitting a following record or suffix to remain in the stream. A previously different destination dimension or value shall not affect a successful result.

Status-field parsing and its outcomes shall follow 🔗 5. Status ASCII loading and partial rejection state. A missing or incorrect space_dim label, an absent, negative-signed or unsupported dimension, or a rejected or truncated coordinate interval record shall return false when stream extraction returns normally. Coordinate loading shall follow 🔗 5. Compatible interval record loading and partial failure state. A completed record that fails the box invariant check shall return false in every build. Stream exception masks and selected endpoint/resource exceptions shall retain their own propagation rules. A complete admissible dimension shall fit the selected box profile and available resources. Use trusted compatible dumps.

Failure may have replaced status and some coordinate records or discarded the previous coordinate sequence. A false return or exception shall not promise rollback or a complete valid mathematical box value. The object shall retain safely destructible owned resources and may be replaced by assignment from a valid box; callers shall establish a valid replacement before mathematical queries or other operations requiring a valid box. Input already consumed shall not be restored. Successful loading shall not transfer ownership of the input stream.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

PPL-SPEC-000972
4. Owned box memory accounting PPL-SPEC-000972

external_memory_in_bytes() shall report the sum of the owned coordinate sequence's allocated slot storage and the external memory reported by every live interval element. If K coordinate slots are allocated and n elements are live, slot storage shall contribute K * sizeof(ITV); each live element's external storage shall be counted once, including elements in a logically empty box. Inactive logical factors shall not cause owned allocated storage to disappear from the accounting.

total_memory_in_bytes() shall report sizeof(Box<ITV>) plus that external count. Object/slot sizes shall be those of the selected build and interval profile. The result shall exclude allocator bookkeeping and independently owned library temporaries or other objects. Successful calls shall require each selected interval's memory query to be well-formed and the sum to fit memory_size_type. The queries shall preserve the represented value, ambient dimension and owned storage.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

PPL-SPEC-001220
5. Box representation invariant query PPL-SPEC-001220

For a live, well-owned and safely indexable box whose selected interval operations are admitted, OK() shall check the following representation conditions. If a current nonempty cache claim is present, the coordinate product shall have no empty factor. Unless the box is certified empty, every coordinate factor shall pass its selected interval OK() query. A violation of a checked condition shall return false; passing these checks shall return true. Zero-dimensional empty and universe shall both pass. Certified empty boxes may retain inactive coordinate storage; its interval validity shall not be a condition of this query.

The receiver's mathematical value, dimension, owned coordinate storage and cached claims shall remain unchanged. The query may copy the box and query interval emptiness on that temporary. Allocation or interval-operation exceptions may propagate; discarded query temporaries shall release their owned storage. Debug builds may emit a diagnostic for an inconsistent nonempty claim; exact diagnostic wording shall not be part of the result.

The interval admission and synchronization conditions of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply to the operations used by the query. Diagnostic use may inspect safely owned but inconsistent cache claims or safely queryable invalid factors. It shall not inspect arbitrary damaged pointers, broken lifetimes or non-indexable fabricated storage. A true result shall not certify arbitrary client preconditions, minimum storage, or that the box is nonempty.