]> git.donarmstrong.com Git - rsem.git/blob - boost/math/policies/error_handling.hpp
Updated boost to v1.55.0
[rsem.git] / boost / math / policies / error_handling.hpp
1 //  Copyright John Maddock 2007.
2 //  Copyright Paul A. Bristow 2007.
3
4 //  Use, modification and distribution are subject to the
5 //  Boost Software License, Version 1.0. (See accompanying file
6 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
9 #define BOOST_MATH_POLICY_ERROR_HANDLING_HPP
10
11 #include <stdexcept>
12 #include <iomanip>
13 #include <string>
14 #include <cerrno>
15 #include <boost/config/no_tr1/complex.hpp>
16 #include <boost/config/no_tr1/cmath.hpp>
17 #include <stdexcept>
18 #include <boost/math/tools/config.hpp>
19 #include <boost/math/policies/policy.hpp>
20 #include <boost/math/tools/precision.hpp>
21 #include <boost/cstdint.hpp>
22 #ifdef BOOST_MSVC
23 #  pragma warning(push) // Quiet warnings in boost/format.hpp
24 #  pragma warning(disable: 4996) // _SCL_SECURE_NO_DEPRECATE
25 #  pragma warning(disable: 4512) // assignment operator could not be generated.
26 // And warnings in error handling:
27 #  pragma warning(disable: 4702) // unreachable code.
28 // Note that this only occurs when the compiler can deduce code is unreachable,
29 // for example when policy macros are used to ignore errors rather than throw.
30 #endif
31 #include <boost/format.hpp>
32
33 namespace boost{ namespace math{
34
35 class evaluation_error : public std::runtime_error
36 {
37 public:
38    evaluation_error(const std::string& s) : std::runtime_error(s){}
39 };
40
41 class rounding_error : public std::runtime_error
42 {
43 public:
44    rounding_error(const std::string& s) : std::runtime_error(s){}
45 };
46
47 namespace policies{
48 //
49 // Forward declarations of user error handlers,
50 // it's up to the user to provide the definition of these:
51 //
52 template <class T>
53 T user_domain_error(const char* function, const char* message, const T& val);
54 template <class T>
55 T user_pole_error(const char* function, const char* message, const T& val);
56 template <class T>
57 T user_overflow_error(const char* function, const char* message, const T& val);
58 template <class T>
59 T user_underflow_error(const char* function, const char* message, const T& val);
60 template <class T>
61 T user_denorm_error(const char* function, const char* message, const T& val);
62 template <class T>
63 T user_evaluation_error(const char* function, const char* message, const T& val);
64 template <class T, class TargetType>
65 T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
66 template <class T>
67 T user_indeterminate_result_error(const char* function, const char* message, const T& val);
68
69 namespace detail
70 {
71 //
72 // Helper function to avoid binding rvalue to non-const-reference,
73 // in other words a warning suppression mechanism:
74 //
75 template <class Formatter, class Group>
76 inline std::string do_format(Formatter f, const Group& g)
77 {
78    return (f % g).str();
79 }
80
81 template <class E, class T>
82 void raise_error(const char* function, const char* message)
83 {
84   if(function == 0)
85        function = "Unknown function operating on type %1%";
86   if(message == 0)
87        message = "Cause unknown";
88
89   std::string msg("Error in function ");
90   msg += (boost::format(function) % typeid(T).name()).str();
91   msg += ": ";
92   msg += message;
93
94   E e(msg);
95   boost::throw_exception(e);
96 }
97
98 template <class E, class T>
99 void raise_error(const char* function, const char* message, const T& val)
100 {
101   if(function == 0)
102      function = "Unknown function operating on type %1%";
103   if(message == 0)
104      message = "Cause unknown: error caused by bad argument with value %1%";
105
106   std::string msg("Error in function ");
107   msg += (boost::format(function) % typeid(T).name()).str();
108   msg += ": ";
109   msg += message;
110
111   int prec = 2 + (boost::math::policies::digits<T, boost::math::policies::policy<> >() * 30103UL) / 100000UL;
112   msg = do_format(boost::format(msg), boost::io::group(std::setprecision(prec), val));
113
114   E e(msg);
115   boost::throw_exception(e);
116 }
117
118 template <class T>
119 inline T raise_domain_error(
120            const char* function,
121            const char* message,
122            const T& val,
123            const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>&)
124 {
125    raise_error<std::domain_error, T>(function, message, val);
126    // we never get here:
127    return std::numeric_limits<T>::quiet_NaN();
128 }
129
130 template <class T>
131 inline T raise_domain_error(
132            const char* ,
133            const char* ,
134            const T& ,
135            const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&)
136 {
137    // This may or may not do the right thing, but the user asked for the error
138    // to be ignored so here we go anyway:
139    return std::numeric_limits<T>::quiet_NaN();
140 }
141
142 template <class T>
143 inline T raise_domain_error(
144            const char* ,
145            const char* ,
146            const T& ,
147            const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&)
148 {
149    errno = EDOM;
150    // This may or may not do the right thing, but the user asked for the error
151    // to be silent so here we go anyway:
152    return std::numeric_limits<T>::quiet_NaN();
153 }
154
155 template <class T>
156 inline T raise_domain_error(
157            const char* function,
158            const char* message,
159            const T& val,
160            const  ::boost::math::policies::domain_error< ::boost::math::policies::user_error>&)
161 {
162    return user_domain_error(function, message, val);
163 }
164
165 template <class T>
166 inline T raise_pole_error(
167            const char* function,
168            const char* message,
169            const T& val,
170            const  ::boost::math::policies::pole_error< ::boost::math::policies::throw_on_error>&)
171 {
172    return boost::math::policies::detail::raise_domain_error(function, message, val,  ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>());
173 }
174
175 template <class T>
176 inline T raise_pole_error(
177            const char* function,
178            const char* message,
179            const T& val,
180            const  ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&)
181 {
182    return  ::boost::math::policies::detail::raise_domain_error(function, message, val,  ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>());
183 }
184
185 template <class T>
186 inline T raise_pole_error(
187            const char* function,
188            const char* message,
189            const T& val,
190            const  ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&)
191 {
192    return  ::boost::math::policies::detail::raise_domain_error(function, message, val,  ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>());
193 }
194
195 template <class T>
196 inline T raise_pole_error(
197            const char* function,
198            const char* message,
199            const T& val,
200            const  ::boost::math::policies::pole_error< ::boost::math::policies::user_error>&)
201 {
202    return user_pole_error(function, message, val);
203 }
204
205
206 template <class T>
207 inline T raise_overflow_error(
208            const char* function,
209            const char* message,
210            const  ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
211 {
212    raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow");
213    // We should never get here:
214    return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
215 }
216
217 template <class T>
218 inline T raise_overflow_error(
219            const char* function,
220            const char* message,
221            const T& val,
222            const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
223 {
224    raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow", val);
225    // We should never get here:
226    return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
227 }
228
229 template <class T>
230 inline T raise_overflow_error(
231            const char* ,
232            const char* ,
233            const  ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&)
234 {
235    // This may or may not do the right thing, but the user asked for the error
236    // to be ignored so here we go anyway:
237    return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
238 }
239
240 template <class T>
241 inline T raise_overflow_error(
242            const char* ,
243            const char* ,
244            const  ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&)
245 {
246    errno = ERANGE;
247    // This may or may not do the right thing, but the user asked for the error
248    // to be silent so here we go anyway:
249    return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
250 }
251
252 template <class T>
253 inline T raise_overflow_error(
254            const char* function,
255            const char* message,
256            const  ::boost::math::policies::overflow_error< ::boost::math::policies::user_error>&)
257 {
258    return user_overflow_error(function, message, std::numeric_limits<T>::infinity());
259 }
260
261
262 template <class T>
263 inline T raise_underflow_error(
264            const char* function,
265            const char* message,
266            const  ::boost::math::policies::underflow_error< ::boost::math::policies::throw_on_error>&)
267 {
268    raise_error<std::underflow_error, T>(function, message ? message : "numeric underflow");
269    // We should never get here:
270    return 0;
271 }
272
273 template <class T>
274 inline T raise_underflow_error(
275            const char* ,
276            const char* ,
277            const  ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&)
278 {
279    // This may or may not do the right thing, but the user asked for the error
280    // to be ignored so here we go anyway:
281    return T(0);
282 }
283
284 template <class T>
285 inline T raise_underflow_error(
286            const char* /* function */,
287            const char* /* message */,
288            const  ::boost::math::policies::underflow_error< ::boost::math::policies::errno_on_error>&)
289 {
290    errno = ERANGE;
291    // This may or may not do the right thing, but the user asked for the error
292    // to be silent so here we go anyway:
293    return T(0);
294 }
295
296 template <class T>
297 inline T raise_underflow_error(
298            const char* function,
299            const char* message,
300            const  ::boost::math::policies::underflow_error< ::boost::math::policies::user_error>&)
301 {
302    return user_underflow_error(function, message, T(0));
303 }
304
305 template <class T>
306 inline T raise_denorm_error(
307            const char* function,
308            const char* message,
309            const T& /* val */,
310            const  ::boost::math::policies::denorm_error< ::boost::math::policies::throw_on_error>&)
311 {
312    raise_error<std::underflow_error, T>(function, message ? message : "denormalised result");
313    // we never get here:
314    return T(0);
315 }
316
317 template <class T>
318 inline T raise_denorm_error(
319            const char* ,
320            const char* ,
321            const T&  val,
322            const  ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&)
323 {
324    // This may or may not do the right thing, but the user asked for the error
325    // to be ignored so here we go anyway:
326    return val;
327 }
328
329 template <class T>
330 inline T raise_denorm_error(
331            const char* ,
332            const char* ,
333            const T& val,
334            const  ::boost::math::policies::denorm_error< ::boost::math::policies::errno_on_error>&)
335 {
336    errno = ERANGE;
337    // This may or may not do the right thing, but the user asked for the error
338    // to be silent so here we go anyway:
339    return val;
340 }
341
342 template <class T>
343 inline T raise_denorm_error(
344            const char* function,
345            const char* message,
346            const T& val,
347            const  ::boost::math::policies::denorm_error< ::boost::math::policies::user_error>&)
348 {
349    return user_denorm_error(function, message, val);
350 }
351
352 template <class T>
353 inline T raise_evaluation_error(
354            const char* function,
355            const char* message,
356            const T& val,
357            const  ::boost::math::policies::evaluation_error< ::boost::math::policies::throw_on_error>&)
358 {
359    raise_error<boost::math::evaluation_error, T>(function, message, val);
360    // we never get here:
361    return T(0);
362 }
363
364 template <class T>
365 inline T raise_evaluation_error(
366            const char* ,
367            const char* ,
368            const T& val,
369            const  ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&)
370 {
371    // This may or may not do the right thing, but the user asked for the error
372    // to be ignored so here we go anyway:
373    return val;
374 }
375
376 template <class T>
377 inline T raise_evaluation_error(
378            const char* ,
379            const char* ,
380            const T& val,
381            const  ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&)
382 {
383    errno = EDOM;
384    // This may or may not do the right thing, but the user asked for the error
385    // to be silent so here we go anyway:
386    return val;
387 }
388
389 template <class T>
390 inline T raise_evaluation_error(
391            const char* function,
392            const char* message,
393            const T& val,
394            const  ::boost::math::policies::evaluation_error< ::boost::math::policies::user_error>&)
395 {
396    return user_evaluation_error(function, message, val);
397 }
398
399 template <class T, class TargetType>
400 inline TargetType raise_rounding_error(
401            const char* function,
402            const char* message,
403            const T& val,
404            const TargetType&,
405            const  ::boost::math::policies::rounding_error< ::boost::math::policies::throw_on_error>&)
406 {
407    raise_error<boost::math::rounding_error, T>(function, message, val);
408    // we never get here:
409    return TargetType(0);
410 }
411
412 template <class T, class TargetType>
413 inline TargetType raise_rounding_error(
414            const char* ,
415            const char* ,
416            const T& val,
417            const TargetType&,
418            const  ::boost::math::policies::rounding_error< ::boost::math::policies::ignore_error>&)
419 {
420    // This may or may not do the right thing, but the user asked for the error
421    // to be ignored so here we go anyway:
422    BOOST_STATIC_ASSERT(std::numeric_limits<TargetType>::is_specialized);
423    return  val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
424 }
425
426 template <class T, class TargetType>
427 inline TargetType raise_rounding_error(
428            const char* ,
429            const char* ,
430            const T& val,
431            const TargetType&,
432            const  ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&)
433 {
434    errno = ERANGE;
435    // This may or may not do the right thing, but the user asked for the error
436    // to be silent so here we go anyway:
437    BOOST_STATIC_ASSERT(std::numeric_limits<TargetType>::is_specialized);
438    return  val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
439 }
440
441 template <class T, class TargetType>
442 inline TargetType raise_rounding_error(
443            const char* function,
444            const char* message,
445            const T& val,
446            const TargetType& t,
447            const  ::boost::math::policies::rounding_error< ::boost::math::policies::user_error>&)
448 {
449    return user_rounding_error(function, message, val, t);
450 }
451
452 template <class T, class R>
453 inline T raise_indeterminate_result_error(
454            const char* function,
455            const char* message,
456            const T& val,
457            const R& ,
458            const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::throw_on_error>&)
459 {
460    raise_error<std::domain_error, T>(function, message, val);
461    // we never get here:
462    return std::numeric_limits<T>::quiet_NaN();
463 }
464
465 template <class T, class R>
466 inline T raise_indeterminate_result_error(
467            const char* ,
468            const char* ,
469            const T& ,
470            const R& result,
471            const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::ignore_error>&)
472 {
473    // This may or may not do the right thing, but the user asked for the error
474    // to be ignored so here we go anyway:
475    return result;
476 }
477
478 template <class T, class R>
479 inline T raise_indeterminate_result_error(
480            const char* ,
481            const char* ,
482            const T& ,
483            const R& result,
484            const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::errno_on_error>&)
485 {
486    errno = EDOM;
487    // This may or may not do the right thing, but the user asked for the error
488    // to be silent so here we go anyway:
489    return result;
490 }
491
492 template <class T, class R>
493 inline T raise_indeterminate_result_error(
494            const char* function,
495            const char* message,
496            const T& val,
497            const R& ,
498            const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::user_error>&)
499 {
500    return user_indeterminate_result_error(function, message, val);
501 }
502
503 }  // namespace detail
504
505 template <class T, class Policy>
506 inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&)
507 {
508    typedef typename Policy::domain_error_type policy_type;
509    return detail::raise_domain_error(
510       function, message ? message : "Domain Error evaluating function at %1%",
511       val, policy_type());
512 }
513
514 template <class T, class Policy>
515 inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&)
516 {
517    typedef typename Policy::pole_error_type policy_type;
518    return detail::raise_pole_error(
519       function, message ? message : "Evaluation of function at pole %1%",
520       val, policy_type());
521 }
522
523 template <class T, class Policy>
524 inline T raise_overflow_error(const char* function, const char* message, const Policy&)
525 {
526    typedef typename Policy::overflow_error_type policy_type;
527    return detail::raise_overflow_error<T>(
528       function, message ? message : "Overflow Error",
529       policy_type());
530 }
531
532 template <class T, class Policy>
533 inline T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&)
534 {
535    typedef typename Policy::overflow_error_type policy_type;
536    return detail::raise_overflow_error(
537       function, message ? message : "Overflow evaluating function at %1%",
538       val, policy_type());
539 }
540
541 template <class T, class Policy>
542 inline T raise_underflow_error(const char* function, const char* message, const Policy&)
543 {
544    typedef typename Policy::underflow_error_type policy_type;
545    return detail::raise_underflow_error<T>(
546       function, message ? message : "Underflow Error",
547       policy_type());
548 }
549
550 template <class T, class Policy>
551 inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&)
552 {
553    typedef typename Policy::denorm_error_type policy_type;
554    return detail::raise_denorm_error<T>(
555       function, message ? message : "Denorm Error",
556       val,
557       policy_type());
558 }
559
560 template <class T, class Policy>
561 inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&)
562 {
563    typedef typename Policy::evaluation_error_type policy_type;
564    return detail::raise_evaluation_error(
565       function, message ? message : "Internal Evaluation Error, best value so far was %1%",
566       val, policy_type());
567 }
568
569 template <class T, class TargetType, class Policy>
570 inline TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&)
571 {
572    typedef typename Policy::rounding_error_type policy_type;
573    return detail::raise_rounding_error(
574       function, message ? message : "Value %1% can not be represented in the target integer type.",
575       val, t, policy_type());
576 }
577
578 template <class T, class R, class Policy>
579 inline T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&)
580 {
581    typedef typename Policy::indeterminate_result_error_type policy_type;
582    return detail::raise_indeterminate_result_error(
583       function, message ? message : "Indeterminate result with value %1%",
584       val, result, policy_type());
585 }
586
587 //
588 // checked_narrowing_cast:
589 //
590 namespace detail
591 {
592
593 template <class R, class T, class Policy>
594 inline bool check_overflow(T val, R* result, const char* function, const Policy& pol)
595 {
596    BOOST_MATH_STD_USING
597    if(fabs(val) > tools::max_value<R>())
598    {
599       *result = static_cast<R>(boost::math::policies::detail::raise_overflow_error<R>(function, 0, pol));
600       return true;
601    }
602    return false;
603 }
604 template <class R, class T, class Policy>
605 inline bool check_overflow(std::complex<T> val, R* result, const char* function, const Policy& pol)
606 {
607    typedef typename R::value_type r_type;
608    r_type re, im;
609    bool r = check_overflow<r_type>(val.real(), &re, function, pol);
610    r = check_overflow<r_type>(val.imag(), &im, function, pol) || r;
611    *result = R(re, im);
612    return r;
613 }
614 template <class R, class T, class Policy>
615 inline bool check_underflow(T val, R* result, const char* function, const Policy& pol)
616 {
617    if((val != 0) && (static_cast<R>(val) == 0))
618    {
619       *result = static_cast<R>(boost::math::policies::detail::raise_underflow_error<R>(function, 0, pol));
620       return true;
621    }
622    return false;
623 }
624 template <class R, class T, class Policy>
625 inline bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol)
626 {
627    typedef typename R::value_type r_type;
628    r_type re, im;
629    bool r = check_underflow<r_type>(val.real(), &re, function, pol);
630    r = check_underflow<r_type>(val.imag(), &im, function, pol) || r;
631    *result = R(re, im);
632    return r;
633 }
634 template <class R, class T, class Policy>
635 inline bool check_denorm(T val, R* result, const char* function, const Policy& pol)
636 {
637    BOOST_MATH_STD_USING
638    if((fabs(val) < static_cast<T>(tools::min_value<R>())) && (static_cast<R>(val) != 0))
639    {
640       *result = static_cast<R>(boost::math::policies::detail::raise_denorm_error<R>(function, 0, static_cast<R>(val), pol));
641       return true;
642    }
643    return false;
644 }
645 template <class R, class T, class Policy>
646 inline bool check_denorm(std::complex<T> val, R* result, const char* function, const Policy& pol)
647 {
648    typedef typename R::value_type r_type;
649    r_type re, im;
650    bool r = check_denorm<r_type>(val.real(), &re, function, pol);
651    r = check_denorm<r_type>(val.imag(), &im, function, pol) || r;
652    *result = R(re, im);
653    return r;
654 }
655
656 // Default instantiations with ignore_error policy.
657 template <class R, class T>
658 inline bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; }
659 template <class R, class T>
660 inline bool check_overflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; }
661 template <class R, class T>
662 inline bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; }
663 template <class R, class T>
664 inline bool check_underflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; }
665 template <class R, class T>
666 inline bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; }
667 template <class R, class T>
668 inline bool check_denorm(std::complex<T> /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; }
669
670 } // namespace detail
671
672 template <class R, class Policy, class T>
673 inline R checked_narrowing_cast(T val, const char* function)
674 {
675    typedef typename Policy::overflow_error_type overflow_type;
676    typedef typename Policy::underflow_error_type underflow_type;
677    typedef typename Policy::denorm_error_type denorm_type;
678    //
679    // Most of what follows will evaluate to a no-op:
680    //
681    R result = 0;
682    if(detail::check_overflow<R>(val, &result, function, overflow_type()))
683       return result;
684    if(detail::check_underflow<R>(val, &result, function, underflow_type()))
685       return result;
686    if(detail::check_denorm<R>(val, &result, function, denorm_type()))
687       return result;
688
689    return static_cast<R>(val);
690 }
691
692 template <class T, class Policy>
693 inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
694 {
695    if(max_iter >= policies::get_max_series_iterations<Policy>())
696       raise_evaluation_error<T>(
697          function,
698          "Series evaluation exceeded %1% iterations, giving up now.", static_cast<T>(static_cast<double>(max_iter)), pol);
699 }
700
701 template <class T, class Policy>
702 inline void check_root_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
703 {
704    if(max_iter >= policies::get_max_root_iterations<Policy>())
705       raise_evaluation_error<T>(
706          function,
707          "Root finding evaluation exceeded %1% iterations, giving up now.", static_cast<T>(static_cast<double>(max_iter)), pol);
708 }
709
710 } //namespace policies
711
712 #ifdef BOOST_MSVC
713 #  pragma warning(pop)
714 #endif
715
716 }} // namespaces boost/math
717
718 #endif // BOOST_MATH_POLICY_ERROR_HANDLING_HPP
719