1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/html4/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
6 | <link rel="stylesheet" type="text/css" href="../../../../boost.css"> |
---|
7 | <title>Policies</title> |
---|
8 | </head> |
---|
9 | |
---|
10 | <body lang="en"> |
---|
11 | <h1>Policies</h1> |
---|
12 | |
---|
13 | <p>The <code>interval</code> template requires two arguments. The first |
---|
14 | corresponds to the base type chosen for the bounds. And the second defines |
---|
15 | the <a href="rounding.htm">rounding</a> and <a |
---|
16 | href="checking.htm">checking</a> behaviors of the newly constructed class. |
---|
17 | This second argument is not mandatory but may need some customizations. In |
---|
18 | order to ease the manipulations, some helper templates are provided in |
---|
19 | <code>interval/policies.hpp</code>.</p> |
---|
20 | <pre>namespace boost { |
---|
21 | namespace numeric { |
---|
22 | namespace interval_lib { |
---|
23 | |
---|
24 | template<class Rounding, class Checking> |
---|
25 | struct policies { |
---|
26 | typedef Rounding rounding; |
---|
27 | typedef Checking checking; |
---|
28 | }; |
---|
29 | |
---|
30 | template<class OldInterval, class NewRounding> |
---|
31 | struct change_rounding { |
---|
32 | typedef ... type; |
---|
33 | }; |
---|
34 | |
---|
35 | template<class OldInterval, class NewChecking> |
---|
36 | struct change_checking { |
---|
37 | typedef ... type; |
---|
38 | }; |
---|
39 | |
---|
40 | template<class OldInterval> |
---|
41 | struct unprotect { |
---|
42 | typedef ... type; |
---|
43 | }; |
---|
44 | |
---|
45 | } // namespace interval_lib |
---|
46 | } // namespace numeric |
---|
47 | } // namespace boost</pre> |
---|
48 | |
---|
49 | <p>The <code>policies</code> template should be used whenever the user needs |
---|
50 | to define a policy structure for an <code>interval</code> class. |
---|
51 | <code>change_rounding</code> and <code>change_checking</code> can be used to |
---|
52 | get the type of a new interval by changing one of the policies of an old |
---|
53 | interval; the new type is available thanks to the type definition |
---|
54 | <code>type</code>. Finally, <code>unprotect</code> looks like |
---|
55 | <code>change_rounding</code> and directly changes the rounding of an interval |
---|
56 | to its unprotected version (a better explanation is available <a |
---|
57 | href="rounding.htm#perfexp">here</a>).</p> |
---|
58 | <hr> |
---|
59 | |
---|
60 | <p>Revised: 2003-01-21<br> |
---|
61 | Copyright (c) Guillaume Melquiond, Sylvain Pion, Hervé Brönnimann, 2002.<br> |
---|
62 | Polytechnic University.</p> |
---|
63 | </body> |
---|
64 | </html> |
---|