Parma Polyhedra Library requirements
C++ numerical policies and operation capabilities
1. Operation-specific numerical policy capabilities PPL-SPEC-000551

Checked_Number<T, Policy> shall obtain numerical checks, special-value capabilities, rounding defaults and result handling from the members of Policy required by the selected operation. Availability of one operation shall not require policy members used only by another operation. Checking and capability flags required by a selected operation shall be constant expressions.

Default construction, same-type copying and raw storage access shall not require a rounding default or handle_result. A named result-returning operation with an explicit Rounding_Dir shall return its Result without invoking a policy handler; its scalar backend's relevant checking and special-value traits shall still be required. Named rational input shall admit the two-trait policy specified by 🔗 2. Canonical rational input and stream failure outcomes.

A value-converting constructor with an explicit direction shall invoke the destination policy's handle_result for the conversion result without requiring a rounding default. The corresponding constructor without a direction shall use ROUND_DEFAULT_CONSTRUCTOR and that handler. Overloaded arithmetic operators shall use ROUND_DEFAULT_OPERATOR; named assignment functions that omit a direction, such as div_2exp_assign, shall use ROUND_DEFAULT_FUNCTION. Each shall pass the numerical result to handle_result after its numerical operation. Handler exceptions shall propagate. Same-type copy assignment shall copy storage without invoking a conversion handler.

Checked stream operators shall have the capability and dispatch rules of 🔗 6. Checked numeric stream policy integration: input uses ROUND_DEFAULT_INPUT and a handler; output uses ROUND_IGNORE and a handler. Neither shall require ROUND_DEFAULT_OUTPUT. Availability of the underlying implicit conversion to T shall require a policy that provides true convertible. Operation-specific numerical, aliasing, resource and synchronization preconditions shall continue to apply. Policy constants and direct policy handlers shall require no library initialization or FPU rounding setup.

PPL-SPEC-000552
2. Transparent numerical policy PPL-SPEC-000552

For supported scalar T, Checked_Number_Transparent_Policy<T> shall provide the following constant boolean traits:

  • check_overflow, check_inf_add_inf, check_inf_sub_inf, check_inf_mul_zero, check_div_zero, check_inf_div_inf, check_inf_mod and check_sqrt_neg shall be false.
  • has_nan shall equal std::numeric_limits<T>::has_quiet_NaN; has_infinity shall equal std::numeric_limits<T>::has_infinity.
  • convertible shall be true; check_fpu_inexact and check_fpu_nan_result shall be false.

Its ROUND_DEFAULT_CONSTRUCTOR, ROUND_DEFAULT_OPERATOR, ROUND_DEFAULT_FUNCTION, ROUND_DEFAULT_INPUT and ROUND_DEFAULT_OUTPUT shall each equal ROUND_NATIVE. handle_result(r) shall return without throwing or changing observable state for every admitted Result code, including diagnostics and unrepresentability flags. It shall not convert a diagnostic into a successful numerical outcome. Numerical operations shall retain their own valid-input, representability and rounding preconditions; disabled checks shall not promise defined native arithmetic outside those preconditions.

PPL-SPEC-000553
3. Result-returning overflow-checking policy PPL-SPEC-000553

For supported scalar T, Check_Overflow_Policy<T> shall provide true check_overflow, convertible, check_fpu_inexact and check_fpu_nan_result. Its check_inf_add_inf, check_inf_sub_inf, check_inf_mul_zero, check_div_zero, check_inf_div_inf, check_inf_mod and check_sqrt_neg shall be false. has_nan shall equal std::numeric_limits<T>::has_quiet_NaN and has_infinity shall equal std::numeric_limits<T>::has_infinity.

The policy shall provide no ROUND_DEFAULT_CONSTRUCTOR, ROUND_DEFAULT_OPERATOR, ROUND_DEFAULT_FUNCTION, ROUND_DEFAULT_INPUT, ROUND_DEFAULT_OUTPUT or handle_result. Checked storage using this policy shall support default construction, raw access and applicable explicit-direction result-returning calls under 🔗 1. Operation-specific numerical policy capabilities. Those calls shall expose overflow and other outcomes through Result according to their individual contracts. Automatic handler dispatch shall require a policy that additionally provides a handler; convenience interfaces using defaults shall additionally require those defaults. Enabling overflow checks shall not enable the seven separate invalid-operation checks listed above.

PPL-SPEC-000554
4. Extended numerical policy and NaN-class handler PPL-SPEC-000554

Extended_Number_Policy shall provide true check_overflow, has_nan, has_infinity, check_fpu_inexact and check_fpu_nan_result. Its check_inf_add_inf, check_inf_sub_inf, check_inf_mul_zero, check_div_zero, check_inf_div_inf, check_inf_mod and check_sqrt_neg shall be false. It shall provide no convertible member and none of the five rounding defaults listed in 🔗 3. Result-returning overflow-checking policy. In particular, supplying this policy shall not enable an implicit conversion to the underlying scalar type.

For admitted Result codes, handle_result(r) shall invoke throw_result_exception(r) exactly when result_class(r) == VC_NAN, with the exception categories specified by 🔗 8. Exception classification of numerical result codes. For every other class it shall return without throwing, including infinity, bounded-overflow and unrepresentability flags. Those other outcomes shall retain their original numerical meanings; normal return from this handler shall not imply successful exact arithmetic or representability.

The special-value capability traits shall enable supported extended representations in the selected scalar backend; they shall not promise that every native storage type can physically encode all such representations. The disabled invalid-operation checks shall retain the underlying operation's preconditions.

PPL-SPEC-000555
5. Bounded integer coefficient policy configuration PPL-SPEC-000555

In bounded integer coefficient configurations, Bounded_Integer_Coefficient_Policy shall provide true check_overflow, convertible and check_fpu_nan_result. Its has_nan, has_infinity and check_fpu_inexact shall be false, as shall check_inf_add_inf, check_inf_sub_inf, check_inf_mul_zero, check_div_zero, check_inf_div_inf, check_inf_mod and check_sqrt_neg. Each of the five rounding defaults listed in 🔗 2. Transparent numerical policy shall equal ROUND_NATIVE.

In checked bounded coefficient configurations, handle_result(r) shall invoke throw_result_exception(r) exactly when result_overflow(r) is true or result_class(r) == VC_NAN, with the categories of 🔗 8. Exception classification of numerical result codes. Otherwise it shall return without throwing. The overflow query shall have the code-sensitive meaning specified by 🔗 3. Overflow-sign and storage-representability result queries, including its treatment of annotated normal-class codes and class-based infinity signs. Checked coefficient operations shall retain the failure guarantees of 🔗 5. Checked coefficient overflow and result-policy dispatch. In unchecked native coefficient configurations, the policy's declaration shall not confer checked arithmetic behavior on the configured native Coefficient type or promise a linkable handler implementation.