Lines Matching full:code
16 <p>A checking policy controls how the <code>interval</code> class will deal
20 <p>For example, let's consider <code>operator+(interval, T)</code>. The
50 <p>The first two functions, <code>pos_inf</code> and <code>neg_inf</code>,
52 interval. For example, <code>interval::whole</code> computes
53 <code>interval(checking::neg_inf(), checking::pos_inf())</code>. If
55 <code>std::numeric_limits<T>::infinity()</code> returns a correct
58 <p>Next comes <code>nan</code>. This function is used each time a function
59 need to return a value of type <code>T</code> but is unable to compute it.
62 <code>nan</code> will be used. But please remember: <code>lower</code> and
63 <code>upper</code> directly return the value stocked in the interval; so,
64 if the interval is empty, <code>lower</code> will not answer
65 <code>by</code> a call to <code>checking::nan</code> (but will return the
66 same value than <code>checking::empty_lower</code> could return).</p>
68 <p><code>empty_lower</code> and <code>empty_upper</code> respectively
70 requirements for <code>empty_lower</code> and <code>empty_upper</code> to
71 return the same value than <code>checking::nan</code>. For example, if the
72 type <code>T</code> does not have any invalid value, the
73 <code>empty_</code> functions can return the [1;0] interval.</p>
75 <p><code>is_nan</code> is used to test if a value of type <code>T</code> is
76 invalid or not. <code>is_empty</code> tests if the interval formed by the
79 <code>T</code>. If one of the inputs is declared invalid, the the function
110 <p>First of all, there is <code>checking_base</code>. Thanks to the
111 information provided by <code>std::numeric_limits<T></code>, this
112 class is able to generate a base for the policy. If <code>T</code> has
113 quiet NaNs (as said by <code>numeric_limits::has_quiet_NaN</code>), then
114 the value is used for <code>nan</code>, <code>empty_lower</code>,
115 <code>empty_upper</code>; and a basic test is used for <code>is_nan</code>
116 (it is <code>x!=x</code>). If <code>T</code> does not have quiet NaNs, then
117 <code>nan</code> is an <code>assert(false)</code>, the empty interval is
118 [1,0], and <code>is_nan</code> always return <code>false</code>. As for
119 <code>nan</code>, <code>pos_inf</code> returns
120 <code>numeric_limits::infinity()</code> if possible, or is an
121 <code>assert(false</code>) otherwise. <code>neg_inf</code> returns the
122 opposite. Finally, <code>is_empty(T l,T u)</code> is always defined by
123 <code>!(l<=u)</code>.</p>
125 <p>Next comes <code>checking_no_empty</code>. Using it means that each time
126 an empty interval should be produced (by <code>empty_lower</code> and
127 <code>empty_upper</code>), the function object given by the
128 <code>Exception</code> argument of the template is invoked and the value it
129 returns is propagated. So, if <code>Exception</code> is appropriately
132 <code>is_empty</code> will always return <code>false</code> (since there is
134 case we can also replace <code>nan</code> by an <code>assert(false)</code>;
139 <p>Finally there are <code>checking_no_nan</code> and
140 <code>checking_catch_nan</code>. The first one expresses the functions of
142 <code>is_nan</code> will only return <code>false</code>. The other one
144 <code>is_nan</code> will call the function object <code>Exception</code>
145 and return <code>false</code>. Indeed, this template means invalid numbers
150 <p><code>exception_create_empty</code> throws
151 <code>std::runtime_error</code> with the message <code>"boost::interval:
152 empty interval created"</code> and <code>exception_invalid_number</code>
153 throws <code>std::invalid_argument</code> with the message
154 <code>"boost::interval: invalid number"</code>.</p>
161 obtain empty intervals, <code>empty_lower</code> and
162 <code>empty_upper</code> have to fail when invoked (they can throw an
165 <code>is_empty</code> may always return <code>false</code>. In this case, a
172 <code>empty_lower</code> and <code>empty_upper</code> need to return
175 <code>is_empty</code> must be able to distinguish empty intervals from the
179 (objects of type <code>T</code>) are invalid? And if it is possible, are
181 <code>is_nan</code> may always return <code>false</code>. In this case too,
184 they are allowed or not. If they are allowed, <code>is_nan</code> just has
186 <code>is_nan</code> should fail (exception, assert, etc.) when invoked on
187 an invalid argument and return <code>false</code> otherwise. The value
188 returned by <code>nan</code> does not have any interest since the interval
193 <p>And finally, you need to decide what to do with <code>nan</code> if it
195 <code>pos_inf</code> and <code>neg_inf</code>. These functions should
204 intervals, then <code>checking_base<T></code> is a
208 the numbers are valid, then <code>checking_catch_nan<T,
209 checking_no_empty<T> ></code> can help you.</li>
213 use <code>checking_no_nan<T, checking_no_empty<T> ></code>.
214 Please note that if <code>T</code> does not have a way to represent
216 <code>checking_no_empty<T></code>. This is the default policy and
217 it is also called <code>interval_lib::checking_strict</code>.</li>
220 manipulate empty intervals, then <code>checking_no_nan<T></code>
224 manipulate empty intervals, the <code>checking_catch_nan<T></code>
229 policy by overloading <code>checking_base</code> and modifying
230 <code>is_nan</code> et <code>is_empty</code> in order for them to always
231 return <code>false</code>. It is probably the fastest checking policy