C++ coordinate types and variables
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
Incoming links from:
1. Bounded-difference values, numerical profiles and valid use
1. Compound-domain values and valid use
1. Rational-grid values, coefficient profile and valid use
1. Octagonal values, numerical profiles and valid use
1. Polyhedral values, coefficient profile and valid use
1. Optimization and ranking valid use
6 |
The public dimension_type shall be an unsigned integral type identical to std::size_t. Let S be its largest representable value. The function not_a_dimension() shall return S, reserved to indicate that no valid dimension is designated. Zero shall be an ordinary index and the dimension of a zero-dimensional space. The type shall not depend on the coefficient profile. The representable index range shall not by itself promise that a particular numerical object supports that many coordinates or that corresponding storage can be allocated. |
A common unsigned coordinate vocabulary distinguishes ordinary coordinates, space-dimension counts and an absent-dimension indication without making a storage-capacity promise. |
|
|
|
|
|
Check type identity with std::size_t, unsigned integral properties and sentinel equality to std::numeric_limits<dimension_type>::max() in C++20. Check zero and boundary arithmetic without overflowing the type. Inspect the configuration-independent declaration and sentinel implementation. Compile a client against installed <ppl.hh> and its matching configured library. |
src/globals_types.hh: dimension_type. src/globals_defs.hh and src/globals_inlines.hh: not_a_dimension. tests/variable1.cc: coordinate_type_and_reserved_value. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. typedef std::size_t dimension_type; dimension_type not_a_dimension(); |
||
|
SW_SPEC
|
2 |
|
|
Incoming link from:
5. Forgetting one coordinate without removing it
1 |
The public Variable type shall represent one Cartesian coordinate by its nonnegative identifier, with limits defined by 🔗 3. Variable construction, coordinate queries and bounds. Its meaning shall depend only on that identifier, independently of C++ object names, other variables and the current output function. Operations on existing variables shall require live valid objects; construction shall require valid source objects only where a source is supplied. Implicit copy and move construction shall create a variable with the source's identifier and shall preserve the source. Implicit copy and move assignment shall set the target's identifier to the source's entry identifier, return a reference to the target and preserve a distinct source. Self-assignment shall preserve the identifier. Each variable shall remain an independent value. These value operations and destruction shall require no external storage allocation; destruction shall not alter another variable. Callers shall prevent unsynchronized access to an object while another operation changes its value. |
Coordinate identity is a value, so copying or disposing of a C++ handle must not rename another coordinate or create shared mutable coordinate storage. |
|
|
|
|
|
Copy, move and assign variables with zero, ordinary and greatest admitted identifiers. Check source preservation, independent later assignment, returned references, chained assignments and self-copy/self-move assignment. Inspect the scalar representation, implicit special members and absence of external storage; check their C++20 trivial-copy and nonthrowing value-operation traits. Use installed-public-header clients for public exposure and matching-library compatibility. Review synchronization separately from sequential value tests. |
src/Variable_defs.hh: public class and scalar representation. tests/variable1.cc: variable_value_operations_preserve_coordinate_identity. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. class Variable; // Callable forms of the implicit public value operations: Variable(const Variable& source); Variable(Variable&& source); Variable& operator=(const Variable& source); Variable& operator=(Variable&& source); ~Variable(); |
||
|
SW_SPEC
|
3 |
|
|
|
Let S = not_a_dimension(). The query Variable::max_space_dimension() shall return S − 1. Construction from i shall succeed exactly for 0 ≤ i < S − 1, subject to ordinary C++ runtime conditions, and shall create a variable with id() == i and space_dimension() == i+1. In particular, the greatest admitted identifier shall be S − 2; its space dimension shall be S − 1. An identifier equal to S − 1 or S shall be rejected with std::length_error without producing a variable. Range rejection shall not rely on wrapping i+1. Exact exception-message text is not prescribed. Queries on a live valid variable shall leave its identifier unchanged and return the exact identifier and enclosing-space dimension. These operations shall not depend on the active formatter or allocate coordinate storage. |
An enclosing space must include the coordinate itself while avoiding the reserved dimension value and unsigned overflow at the upper boundary. |
|
|
|
|
|
Check zero, ordinary identifiers, alphabet boundaries and the greatest admitted identifier against independent arithmetic. Check exact std::length_error type for both rejected boundary values, then construct and query another valid variable. Inspect the comparison performed before addition and query formulas. Exercise both assertion regimes without allocating a coordinate-sized object. |
src/Variable_defs.hh and src/Variable_inlines.hh: constructor and queries. tests/variable1.cc: variable_bounds_and_dimensions. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. explicit Variable(dimension_type i); static dimension_type max_space_dimension(); dimension_type id() const; dimension_type space_dimension() const; |
||
|
SW_SPEC
|
4 |
|
|
|
For live valid variables v and w, less(v, w) and Variable::Compare{}(v, w) shall both return true exactly when v.id() < w.id(). They shall leave the operands unchanged. Equal identifiers shall compare false in both directions, independently of object identity or formatted names. The predicates shall define a strict total ordering of coordinate identifiers and shall allocate no storage. |
Ordered coordinate containers require one consistent ordering that preserves coordinate identity even when output names are customized. |
|
|
|
|
|
Compare all pairs in an independently ordered sample containing duplicates, zero and the greatest admitted identifier. Check both predicates against index comparison, irreflexivity, reversed unequal pairs and transitivity. Verify unchanged identifiers and inspect allocation-free implementations. |
src/Variable_defs.hh and src/Variable_inlines.hh: less and Compare. tests/variable1.cc: variable_ordering_matches_identifier_order. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. bool less(Variable v, Variable w); struct Variable::Compare { bool operator()(Variable v, Variable w) const; }; |
||
|
SW_SPEC
|
5 |
|
|
|
For live valid variables x and y, both x.m_swap(y) and swap(x, y) shall exchange their entry identifiers exactly and leave both variables valid. When both arguments designate the same variable, its identifier shall remain unchanged. Exchange shall allocate no storage and shall not depend on formatted names or the active output function. |
Coordinate values need a constant-storage exchange operation with defined aliasing behavior for generic value manipulation. |
|
|
|
|
|
Check member and nonmember exchange of distinct values, equal identifiers, zero and the greatest admitted identifier. Check self-exchange through both entry points. Verify both identifiers, dimensions and validity after each call; inspect the scalar exchange for absence of allocation. |
src/Variable_defs.hh and src/Variable_inlines.hh: exchange functions. tests/variable1.cc: variable_swap_exchanges_only_the_two_values. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. void m_swap(Variable& other); void swap(Variable& x, Variable& y); |
||
|
SW_SPEC
|
6 |
|
|
|
For every live valid variable, OK() shall return true without changing its value. The representation invariant checked by OK() shall be id() < max_space_dimension(). external_memory_in_bytes() shall return zero and total_memory_in_bytes() shall return sizeof(Variable): variables shall own no separately allocated coordinate storage. These queries shall leave the identifier and formatter state unchanged and shall allocate no storage. No operation shall require constructing an invalid object to use this diagnostic. |
Validity and memory reports make the compact coordinate-value representation observable without exposing or manufacturing invalid object states. |
|
|
|
|
|
Check validity and both memory reports for zero, ordinary and greatest admitted identifiers and after copying, assignment and exchange. Compare total memory with sizeof(Variable), preserving identifiers and the active formatter. Inspect the invariant check and scalar representation; do not corrupt an object solely to execute a diagnostic failure path. |
src/Variable_defs.hh, src/Variable_inlines.hh and src/Variable.cc: validity and memory-accounting queries. tests/variable1.cc: variable_validity_and_memory_are_value_independent. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. bool OK() const; memory_size_type external_memory_in_bytes() const; memory_size_type total_memory_in_bytes() const; |
||
|
SW_SPEC
|
7 |
|
|
Incoming links from:
1. Human-readable bounded-difference presentation
1. Human-readable box presentation
14. Readable congruence and system output
12. Readable constraint and system output
3. Thread initialization, default state and finalization
14. Human-readable affine output and formatter dispatch
1. Human-readable octagonal presentation
8. Coordinate-map diagnostic printing and output failures
6. Coordinate-set diagnostic output and formatter prerequisites
8. Variable names, formatter dispatch and output failures
10 |
The public output_function_type shall denote a function accepting an output stream and a Variable value, returning void. set_output_function(p) shall store exactly p without invoking it; get_output_function() shall return the pointer currently stored for the applicable runtime context. Neither operation shall allocate storage or change any variable identifier. The applicable initialization and thread-entry protocol of 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization shall establish the default output function before variable insertion is used. In a thread-safe build the stored pointer shall be thread-local. Otherwise it shall be shared within the process, and callers shall serialize formatter changes and uses. Callers shall also synchronize shared-stream access and mutable callback state as needed. Storing a null pointer shall be permitted, and a subsequent getter shall return null; insertion shall require a nonnull callable pointer. The caller shall retain any callback dependencies for its use period and restore a callable pointer before subsequent insertion. Setting a formatter shall not acquire ownership of callback dependencies. This interface shall not diagnose every violation of initialization, callback-lifetime or concurrency preconditions. |
Separating the current callback from coordinate identity permits user naming and thread-specific names while making callback validity and ownership explicit. |
|
|
|
|
|
Check the initialized default pointer, exact set/get round trips for distinct callbacks, absence of callback invocation during set/get, null storage followed by restoration and unchanged coordinate values. In thread-safe builds initialize workers through the supported thread protocol and check isolated pointers and output on separate streams while preserving the parent pointer. Review the shared-pointer and callback-state synchronization conditions in other builds. Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
src/Variable_defs.hh, src/Variable_inlines.hh and src/Variable.cc: formatter type, accessors and configured pointer storage. src/Init.cc: default formatter installation at thread initialization. tests/variable1.cc: variable_formatter_pointer_round_trips_without_calls and variable_formatters_are_thread_local. tests/threadsafepublic1.cc: Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. typedef void output_function_type(std::ostream& s, const Variable v); static void set_output_function(output_function_type* p); static output_function_type* get_output_function(); |
||
|
SW_SPEC
|
8 |
|
|
|
For a live valid variable with identifier i, let q = ⌊i ⁄ 26⌋ and r = i − 26q. Successful direct use of default_output_function shall insert the uppercase character at position r in ABCDEFGHIJKLMNOPQRSTUVWXYZ. If q is nonzero, it shall then insert q as an unsigned integer using the stream's current formatting; otherwise it shall insert no suffix. Character and integer insertions shall honor their applicable stream formatting and locale. The function shall add no separator, newline or explicit flush, and shall not change the active formatter. Under 🔗 7. Active Variable formatter and initialized thread state, IO_Operators::operator<< shall invoke the currently active output function exactly once with the supplied stream and variable value, and shall return that same stream reference on normal return. Each insertion shall obtain the pointer active for that call. A callback may change the formatter for subsequent calls; insertion shall not restore the old pointer or undo callback changes to the stream. Direct default formatting shall not consult the active pointer. Output shall not change the variable identifier. Stream failures shall follow the stream's state and exception-mask rules. Callback exceptions and applicable C++ resource exceptions shall propagate; partial output and callback changes to formatter or stream state shall remain observable, with no output rollback promised. Callbacks shall satisfy the stream, lifetime and synchronization preconditions and shall not invalidate an object accessed by the call. |
Default coordinate names are compact and deterministic under a given stream format, while direct callback dispatch preserves customization and ordinary C++ stream failure semantics. |
|
|
|
|
|
Check independent expected names across alphabet and quotient boundaries and at the greatest admitted identifier. Check width, fill, alignment, integer base, locale, returned stream identity and absence of an added newline or explicit flush. Check exactly one callback invocation and the passed identifier, direct default formatting with another callback active, callback changes between successive insertions, a prefailed stream, rejecting streams with exceptions disabled and enabled, and a callback that changes state before throwing. Verify unchanged identifiers and retained callback/stream effects on failures. |
src/Variable_defs.hh and src/Variable.cc: default output and insertion. tests/variable1.cc: default-name, formatting, dispatch and failure checks. |
|
|
Public header: <ppl.hh>. Declarations in Parma_Polyhedra_Library; member declarations belong to Variable unless qualified otherwise. static void default_output_function(std::ostream& s, const Variable v); namespace IO_Operators { std::ostream& operator<<(std::ostream& s, const Variable v); } |