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