Parma Polyhedra Library requirements
C++ finite checked scalar objects
1. Finite checked scalar storage and copying PPL-SPEC-000556

For T drawn from the eleven standard native integer types, mpz_class, mpq_class or a configured supported native floating format, Checked_Number<T, Policy> shall own one scalar value. Its policy shall admit that scalar's representation and the operations used below. Finite rational storage shall be canonical, with positive denominator.

Native_Number<T> shall have the truth value of Is_Native<T>::value. The default classification shall include the scalar families above and shall exclude bool, wide character types, checked wrappers and cv-qualified or reference types; it shall not strip qualifiers. Existing trait specializations shall continue to determine admission. This numeric classification shall not require Boolean equality or alter symbolic Variable comparisons. Native_Or_Checked_Number<T> shall have the truth value of Is_Native_Or_Checked<T>::value and classify raw scalars or checked wrappers. Its default classification shall exclude marker types and retain the same qualifier and trait-specialization rules. Numeric function templates shall use these classifications as constraints without requiring regular Boolean equality for unrelated symbolic types.

Default construction shall produce finite mathematical zero. Native floating zero shall initially have positive sign. Same-type copy construction and copy assignment shall preserve the source value, including a finite native floating zero's sign. The copied object's storage shall be independent of the source: changing or destroying one shall not change or invalidate the other. Same-object copy assignment shall preserve the value and return a reference to that object. Distinct-object copy assignment shall return a reference to the destination and preserve the source. Copying shall not invoke a policy conversion handler or require a rounding default.

A default-constructed or copied object shall be live, assignable and destructible. Copying shall require sufficient resources for the underlying scalar copy. Sources and existing assignment destinations shall be live; callers shall synchronize access overlapping modification of either object. No library initialization, coefficient constants or FPU rounding setup shall be required.

2. Finite checked scalar converting construction and assignment PPL-SPEC-000557

Finite value-converting Checked_Number<T, Policy> constructors shall convert their admitted native, unbounded integer, rational or checked scalar source with the numerical meaning and preconditions of the corresponding assign_r operation. An explicit direction shall select that conversion; a constructor without a direction shall use Policy::ROUND_DEFAULT_CONSTRUCTOR. A C-string constructor shall use the numeric input meaning of 🔗 1. Exact finite numeric token syntax through 🔗 4. Numeric text input into supported native floating destinations, with that explicit or default constructor direction. The string shall point to an accessible null-terminated token.

After conversion returns a Result, construction shall pass it once to Policy::handle_result. On normal handler return, the new object's stored value and any destination-value limitations shall be those of the conversion result. Handler exceptions shall propagate; a constructor that throws shall not produce a usable object. Numerical source objects shall remain unchanged.

Assignment from an admitted source of a different checked type or from a native, unbounded integer or rational source shall use assign_r with Policy::ROUND_DEFAULT_OPERATOR. It shall pass the result once to the handler and, on normal handler return, return a reference to the destination. Same-type copy assignment shall instead follow 🔗 1. Finite checked scalar storage and copying. A handler that throws shall not imply rollback of an assignment; guarantees for the surviving destination shall follow the numerical operation involved.

Required policy members shall follow 🔗 1. Operation-specific numerical policy capabilities. A finite source shall be admissible to its policy and the destination conversion; ROUND_NOT_NEEDED shall retain its exactness and intermediate-operation preconditions. Source lifetimes, resources, synchronization, shared-temporary serialization and any FPU prerequisites shall be those of the corresponding conversion or input contract. No additional library initialization shall be required by the wrapper.

PPL-SPEC-000558
3. Checked scalar storage references and value conversion PPL-SPEC-000558

For a live finite Checked_Number<T, Policy> admitted by 🔗 1. Finite checked scalar storage and copying, mutable raw_value() and the corresponding free raw_value shall return references to the same owned T object. Their const overloads shall return const references to that object without copying or changing its value. A reference shall remain associated with the same storage object until its owner is destroyed; changing the owned value shall not rebind it. Callers that modify raw storage shall maintain its representation and policy prerequisites, including canonical rational form.

The conversion shall participate only when Policy::convertible is a constant expression with a true Boolean value. A missing, false or nonconstant flag shall leave default construction and raw access available without advertising this conversion. Policy access granted to the checked class shall remain usable for this decision.

Where conversion is enabled, conversion to T shall return an independent value copy, preserving the finite value and native floating zero sign. Altering that copy shall not alter the checked object. Raw access and this value conversion shall not invoke a result handler or numerical rounding. The policy restrictions of 🔗 1. Operation-specific numerical policy capabilities shall apply to underlying value conversion. No initialization or FPU rounding setup shall be required; callers shall synchronize access overlapping modification of the owner.

PPL-SPEC-000559
4. Checked scalar value swap PPL-SPEC-000559

For live Checked_Number<T, Policy> objects with the same scalar type and policy and admitted finite or special values, swap(x, y) shall exchange their stored values, including native floating zero signs and admitted infinity signs. An admitted NaN shall remain NaN; ordered equality shall not be required to compare it with its former value. Policies shall remain the template policies of their respective objects. Same-object swap shall preserve the value. Existing raw references shall continue to refer to their original owned storage objects and shall observe the exchanged values.

Swap shall not perform numerical conversion, consult a rounding default or invoke a result handler. It shall require the scalar's swap resources and representation prerequisites, and shall preserve both objects' assignability and destructibility on successful return. Callers shall synchronize access overlapping modification of either object. No initialized library state or FPU rounding setup shall be required.

PPL-SPEC-000560
5. Checked scalar memory-size inspection PPL-SPEC-000560

For a live finite checked scalar admitted by 🔗 1. Finite checked scalar storage and copying, external_memory_in_bytes(x) shall report the same memory-size metric as that query applied to the owned scalar x.raw_value(). total_memory_in_bytes(x) shall likewise report the corresponding owned scalar's total-size metric. For native integer and supported native floating storage, external size shall be zero and total size shall be sizeof(T). For GMP integer and rational storage, the metric shall include the owned scalar's allocated limb storage according to the underlying memory queries. It shall describe allocated storage, rather than only significant digits.

Both queries shall preserve the object and any retained raw references and shall neither invoke policy handlers nor perform numerical rounding. Results shall fit memory_size_type. Callers shall synchronize inspection with modification of the inspected object. No library initialization or FPU rounding setup shall be required.

PPL-SPEC-001197
6. Complete checked-wrapper placement construction without a handler PPL-SPEC-001197

For an admitted call to the result-returning free construct function with To = Checked_Number<T, Policy>, the destination shall denote suitably aligned storage sufficient for that complete wrapper, with no live complete wrapper occupying it. T shall be an admitted native integer, configured native floating format, mpz_class or mpq_class. A numerical source shall be live and initialized; a typed special marker shall have its existing marker meaning. Source storage shall not overlap the unconstructed destination. The selected source/destination policies, scalar conversion and rounding request shall satisfy their existing numerical, representation, resource, initialization, FPU and synchronization prerequisites.

On normal return, a complete destination wrapper and its owned scalar shall have begun their lifetimes. The wrapper shall admit destruction and subsequent supported assignment. The represented result and returned Result shall have the selected checked conversion or typed-special assignment meaning. A failure or unrepresentable result shall not promise a numerical payload that its result and policy do not otherwise define. The source shall be preserved. The free function shall apply its existing exactness-request translation and result check once, without invoking a policy result handler or requiring a constructor rounding default. Both deduced calls and calls that explicitly specify To and From shall have this meaning.

If conversion throws after an owned class scalar has been initialized, ordinary constructor unwinding shall destroy that scalar. No complete destination wrapper is returned from the failed construction. This rule shall not imply an allocation rollback guarantee for the containing row or a live wrapper that the caller must destroy after a failed constructor. Raw native/GMP construction routes and ordinary public wrapper constructors shall retain their existing contracts; in particular, this no-handler function shall not replace the result handling of an ordinary converting constructor.