C++ checked scalar special-marker wrappers
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
|
For Checked_Number<T, Policy>, the underlying type T shall be an admitted native integer, mpz_class, mpq_class or configured supported native floating-point type. Native floating-point policies shall admit the format's infinities and quiet NaN. Marker types shall be Minus_Infinity, Plus_Infinity and Not_A_Number. The explicit-direction marker constructor shall assign the special marker using the supplied direction and deliver that numerical Result exactly once to Policy::handle_result. It shall require that handler but no policy default direction. The default-direction marker constructor shall instead use Policy::ROUND_DEFAULT_CONSTRUCTOR and deliver the result exactly once to that same handler. Assignment from a marker shall use Policy::ROUND_DEFAULT_OPERATOR, deliver its result exactly once to the handler and return a reference to the destination if the handler returns. An assignment default shall not be required merely to construct an object, nor a constructor default merely to assign to a live object. Numerical payloads, supported/unsupported classes, representability flags and admitted directions shall follow 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage or 🔗 4. Typed special-value assignment to native floating-point storage according to storage. In particular, supported NaN representation shall not produce a false unrepresentability flag. A NaN marker shall retain an empty ordered relation and shall not admit ROUND_NOT_NEEDED. Handler acceptance shall not turn an unsupported numerical result into a represented number: such an accepted object shall remain reusable as a destination, without inspecting its unspecified payload. A handler exception shall propagate. Failed construction shall not leave a completed destination object; already constructed members shall have normal C++ cleanup. If assignment's handler throws, the destination shall remain live and reusable but need not retain its old payload. No strong assignment rollback shall be required. Marker sources shall remain unchanged. Underlying object ownership and cleanup shall follow 🔗 1. Finite checked scalar storage and copying. Object access overlapping mutation shall be synchronized, and resources shall suffice for underlying objects. Calls shall require no library initialization, coefficient-constant stage or FPU setup and shall preserve hardware direction. Unavailable floating-point formats shall not be instantiated. Native floating-point exception/status conditions shall follow 🔗 4. Typed special-value assignment to native floating-point storage. |
Convenience construction and assignment apply a caller-selected result policy. That policy must receive the actual numerical outcome once, with the correct default source and ordinary C++ exception/lifetime effects. |
|
|
|
|
|
Use recording and throwing policies to check exact handler call counts and results, explicit directions without defaults, constructor-only and assignment-only defaults, and distinct constructor/operator rounding choices. Check supported and unsupported marker outcomes across storage families, returned assignment identity, unchanged markers, handler exceptions and destination reuse after assignment failure. Cross both values of the ignored Boolean parameter. Check all admitted requests, available floating formats and hardware directions without initialization; require truthful supported-NaN flags. |
src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; src/checked_int_inlines.hh; src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/checked_float_inlines.hh; tests/checkedspecialwrappersspec1.cc. |
|
|
Public header: <ppl.hh>; members of an admitted Checked_Number<T, Policy>: template <Special_Marker Special> Checked_Number(const Special&, Rounding_Dir dir, bool ignored = false); template <Special_Marker Special> Checked_Number(const Special&, bool ignored = false); template <typename From> Checked_Number& operator=(const From&); The optional Boolean parameter shall be ignored for either value. The assignment instantiations admitted here shall have From equal to one of the three special-marker types. |