$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: pbristow_at_[hidden]
Date: 2007-07-26 07:19:54
Author: pbristow
Date: 2007-07-26 07:19:53 EDT (Thu, 26 Jul 2007)
New Revision: 7543
URL: http://svn.boost.org/trac/boost/changeset/7543
Log:
updated to use policy and show use of #define policy macro (but not in boost/math/tools/user.hpp)
Text files modified: 
   sandbox/math_toolkit/libs/math/example/error_handling_example.cpp |    48 ++++++++++++++++++++------------------- 
   1 files changed, 25 insertions(+), 23 deletions(-)
Modified: sandbox/math_toolkit/libs/math/example/error_handling_example.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/example/error_handling_example.cpp	(original)
+++ sandbox/math_toolkit/libs/math/example/error_handling_example.cpp	2007-07-26 07:19:53 EDT (Thu, 26 Jul 2007)
@@ -1,6 +1,6 @@
 // example_error_handling.cpp
 
-// Copyright Paul A. Bristow 2006.
+// Copyright Paul A. Bristow 2007.
 // Copyright John Maddock 2006.
 
 // Use, modification and distribution are subject to the
@@ -8,25 +8,22 @@
 // (See accompanying file LICENSE_1_0.txt
 // or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-// Uncomment these line(s) to enable throw on errors.
-#define BOOST_MATH_THROW_ON_DOMAIN_ERROR
-//#define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
-//#define BOOST_MATH_THROW_ON_OVERFLOW_ERROR
-//#define BOOST_MATH_THROW_ON_UNDERFLOW_ERROR
-//#define BOOST_MATH_THROW_ON_DENORM_ERROR
+// Shows use of macro definition to change policy for
+// domain_error - negative degrees of freedom argument
+// for student's t distribution CDF.
+
+// Uncomment this line to see the effect of changing policy.
+// #define BOOST_MATH_DOMAIN_ERROR_POLICY ignore_error
+// Note that these policy #defines MUST preceed the #include of
+// any boost/math #includes.
+// If placed after, they will have no effect!
+// warning C4005: 'BOOST_MATH_OVERFLOW_ERROR_POLICY' : macro redefinition
+// is a warning that it will NOT have the desired effect.
 
 // Boost
 #include <boost/math/distributions/students_t.hpp>
         using boost::math::students_t;  // Probability of students_t(df, t).
 
-#include <boost/math/tools/error_handling.hpp> // for domain_error.
-	using ::boost::math::tools::domain_error;
-	using ::boost::math::tools::pole_error;
-	using ::boost::math::tools::overflow_error;
-	using ::boost::math::tools::underflow_error;
-	using ::boost::math::tools::denorm_error;
-	using ::boost::math::tools::logic_error;
-
 // std
 #include <iostream>
         using std::cout;
@@ -40,8 +37,11 @@
         cout << "Example error handling using Student's t function. " << endl;
 
   double degrees_of_freedom = -1; double t = -1.; // Bad arguments!
+  // If we use
   // cout << "Probability of Student's t is " << cdf(students_t(-1), -1) << endl; 
-  // Will terminate/abort if #define BOOST_MATH_THROW_ON_DOMAIN_ERROR without try & catch.
+  // Will terminate/abort (without try & catch blocks)
+  // if BOOST_MATH_DOMAIN_ERROR_POLICY has the default value throw_on_error.
+
   try
   {
     cout << "Probability of Student's t is " << cdf(students_t(degrees_of_freedom), t) << endl; 
@@ -51,6 +51,7 @@
     std::cout <<
       "\n""Message from thrown exception was:\n   " << e.what() << std::endl;
   }
+
         return 0;
 } // int main()
 
@@ -60,19 +61,20 @@
 
 Example error handling using Student's t function.
 
-Without
+With
 
-#define BOOST_MATH_THROW_ON_DOMAIN_ERROR 
+#define BOOST_MATH_DOMAIN_ERROR_POLICY ignore_error
 
+Example error handling using Student's t function. 
 Probability of Student's t is 1.#QNAN
 
-With
+Default behaviour without
 
-#define BOOST_MATH_THROW_ON_DOMAIN_ERROR 
+//#define BOOST_MATH_THROW_ON_DOMAIN_ERROR 
 
+Example error handling using Student's t function. 
 Message from thrown exception was:
-   Error in function __thiscall
-   boost::math::students_t_distribution<double>::students_t_distribution(double):
-   Degrees of freedom argument is -1, but must be > 0 !
+   Error in function boost::math::students_t_distribution<double>::students_t_distribution: Degrees of freedom argument is -1, but must be > 0 !
+
 
 */