Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Policy Class Reference

There's very little to say here, the policy class is just a rag-bag compile-time container for a collection of policies:

#include <boost/math/policies/policy.hpp>
namespace boost{
namespace math{
namespace policies

template <class A1 = default_policy,
          class A2 = default_policy,
          class A3 = default_policy,
          class A4 = default_policy,
          class A5 = default_policy,
          class A6 = default_policy,
          class A7 = default_policy,
          class A8 = default_policy,
          class A9 = default_policy,
          class A10 = default_policy,
          class A11 = default_policy,
          class A12 = default_policy,
          class A13 = default_policy>
struct policy
{
public:
   typedef computed-from-template-arguments domain_error_type;
   typedef computed-from-template-arguments pole_error_type;
   typedef computed-from-template-arguments overflow_error_type;
   typedef computed-from-template-arguments underflow_error_type;
   typedef computed-from-template-arguments denorm_error_type;
   typedef computed-from-template-arguments rounding_error_type;
   typedef computed-from-template-arguments evaluation_error_type;
   typedef computed-from-template-arguments indeterminate_result_error_type;
   typedef computed-from-template-arguments precision_type;
   typedef computed-from-template-arguments promote_float_type;
   typedef computed-from-template-arguments promote_double_type;
   typedef computed-from-template-arguments discrete_quantile_type;
   typedef computed-from-template-arguments assert_undefined_type;
};

template <...argument list...>
typename normalise<policy<>, A1>::type make_policy(...argument list..);

template <class Policy,
          class A1 = default_policy,
          class A2 = default_policy,
          class A3 = default_policy,
          class A4 = default_policy,
          class A5 = default_policy,
          class A6 = default_policy,
          class A7 = default_policy,
          class A8 = default_policy,
          class A9 = default_policy,
          class A10 = default_policy,
          class A11 = default_policy,
          class A12 = default_policy,
          class A13 = default_policy>
struct normalise
{
   typedef computed-from-template-arguments type;
};

The member typedefs of class policy are intended for internal use but are documented briefly here for the sake of completeness.

policy<...>::domain_error_type

Specifies how domain errors are handled, will be an instance of boost::math::policies::domain_error<> with the template argument to domain_error one of the error_policy_type enumerated values.

policy<...>::pole_error_type

Specifies how pole-errors are handled, will be an instance of boost::math::policies::pole_error<> with the template argument to pole_error one of the error_policy_type enumerated values.

policy<...>::overflow_error_type

Specifies how overflow errors are handled, will be an instance of boost::math::policies::overflow_error<> with the template argument to overflow_error one of the error_policy_type enumerated values.

policy<...>::underflow_error_type

Specifies how underflow errors are handled, will be an instance of boost::math::policies::underflow_error<> with the template argument to underflow_error one of the error_policy_type enumerated values.

policy<...>::denorm_error_type

Specifies how denorm errors are handled, will be an instance of boost::math::policies::denorm_error<> with the template argument to denorm_error one of the error_policy_type enumerated values.

policy<...>::rounding_error_type

Specifies how rounding errors are handled, will be an instance of boost::math::policies::rounding_error<> with the template argument to rounding_error one of the error_policy_type enumerated values.

policy<...>::evaluation_error_type

Specifies how evaluation errors are handled, will be an instance of boost::math::policies::evaluation_error<> with the template argument to evaluation_error one of the error_policy_type enumerated values.

policy<...>::indeterminate_error_type

Specifies how indeterminate result errors are handled, will be an instance of boost::math::policies::indeterminate_result_error<> with the template argument to indeterminate_result_error one of the error_policy_type enumerated values.

policy<...>::precision_type

Specifies the internal precision to use in binary digits (uses zero to represent whatever the default precision is). Will be an instance of boost::math::policies::digits2<N> which in turn inherits from boost::boost::integral_constant<int, N>.

policy<...>::promote_float_type

Specifies whether or not to promote float arguments to double precision internally. Will be an instance of boost::math::policies::promote_float<B> which in turn inherits from boost::integral_constant<bool, B>.

policy<...>::promote_double_type

Specifies whether or not to promote double arguments to long double precision internally. Will be an instance of boost::math::policies::promote_float<B> which in turn inherits from boost::integral_constant<bool, B>.

policy<...>::discrete_quantile_type

Specifies how discrete quantiles are evaluated, will be an instance of boost::math::policies::discrete_quantile<> instantiated with one of the discrete_quantile_policy_type enumerated type.

policy<...>::assert_undefined_type

Specifies whether mathematically-undefined properties are asserted as compile-time errors, or treated as runtime errors instead. Will be an instance of boost::math::policies::assert_undefined<B> which in turn inherits from boost::integral_constant<bool, B>.

template <...argument list...>
typename normalise<policy<>, A1>::type make_policy(...argument list..);

make_policy is a helper function that converts a list of policies into a normalised policy class.

template <class Policy,
          class A1 = default_policy,
          class A2 = default_policy,
          class A3 = default_policy,
          class A4 = default_policy,
          class A5 = default_policy,
          class A6 = default_policy,
          class A7 = default_policy,
          class A8 = default_policy,
          class A9 = default_policy,
          class A10 = default_policy,
          class A11 = default_policy,
          class A12 = default_policy,
          class A13 = default_policy>
struct normalise
{
   typedef computed-from-template-arguments type;
};

The normalise class template converts one instantiation of the policy class into a normalised form. This is used internally to reduce code bloat: so that instantiating a special function on policy<A,B> or policy<B,A> actually both generate the same code internally.

Further more, normalise can be used to combine a policy with one or more policies: for example many of the special functions will use this to set policies which they don't make use of to their default values, before forwarding to the actual implementation. In this way code bloat is reduced, since the actual implementation depends only on the policy types that they actually use.


PrevUpHomeNext