Policies

The interval template requires two arguments. The first corresponds to the base type chosen for the bounds. And the second defines the rounding and checking behaviors of the newly constructed class. This second argument is not mandatory but may need some customizations. In order to ease the manipulations, some helper templates are provided in interval/policies.hpp.

namespace boost {
namespace numeric {
namespace interval_lib {

template<class Rounding, class Checking>
struct policies {
  typedef Rounding rounding;
  typedef Checking checking;
};

template<class OldInterval, class NewRounding>
struct change_rounding {
  typedef ... type;
};

template<class OldInterval, class NewChecking>
struct change_checking {
  typedef ... type;
};

template<class OldInterval>
struct unprotect {
  typedef ... type;
};

} // namespace interval_lib
} // namespace numeric
} // namespace boost

The policies template should be used whenever the user needs to define a policy structure for an interval class. change_rounding and change_checking can be used to get the type of a new interval by changing one of the policies of an old interval; the new type is available thanks to the type definition type. Finally, unprotect looks like change_rounding and directly changes the rounding of an interval to its unprotected version (a better explanation is available here).


Revised: 2003-01-21
Copyright (c) Guillaume Melquiond, Sylvain Pion, Hervé Brönnimann, 2002.
Polytechnic University.