source: NonGTP/Boost/boost/numeric/interval/policies.hpp @ 857

Revision 857, 1.8 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1/* Boost interval/policies.hpp template implementation file
2 *
3 * Copyright 2003 Guillaume Melquiond
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or
7 * copy at http://www.boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_NUMERIC_INTERVAL_POLICIES_HPP
11#define BOOST_NUMERIC_INTERVAL_POLICIES_HPP
12
13#include <boost/numeric/interval/interval.hpp>
14
15namespace boost {
16namespace numeric {
17namespace interval_lib {
18
19/*
20 * policies class
21 */
22
23template<class Rounding, class Checking>
24struct policies
25{
26  typedef Rounding rounding;
27  typedef Checking checking;
28};
29
30/*
31 * policies switching classes
32 */
33
34template<class OldInterval, class NewRounding>
35class change_rounding
36{
37  typedef typename OldInterval::base_type T;
38  typedef typename OldInterval::traits_type p;
39  typedef typename p::checking checking;
40public:
41  typedef interval<T, policies<NewRounding, checking> > type;
42};
43
44template<class OldInterval, class NewChecking>
45class change_checking
46{
47  typedef typename OldInterval::base_type T;
48  typedef typename OldInterval::traits_type p;
49  typedef typename p::rounding rounding;
50public:
51  typedef interval<T, policies<rounding, NewChecking> > type;
52};
53
54/*
55 * Protect / unprotect: control whether the rounding mode is set/reset
56 * at each operation, rather than once and for all.
57 */
58
59template<class OldInterval>
60class unprotect
61{
62  typedef typename OldInterval::base_type T;
63  typedef typename OldInterval::traits_type p;
64  typedef typename p::rounding r;
65  typedef typename r::unprotected_rounding newRounding;
66public:
67  typedef typename change_rounding<OldInterval, newRounding>::type type;
68};
69
70} // namespace interval_lib
71} // namespace numeric
72} // namespace boost
73
74
75#endif // BOOST_NUMERIC_INTERVAL_POLICIES_HPP
Note: See TracBrowser for help on using the repository browser.