]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/policy_eg_5.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / math / example / policy_eg_5.cpp
1 // Copyright John Maddock 2007.
2 // Copyright Paul A. Bristow 2010
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 // Note that this file contains quickbook mark-up as well as code
8 // and comments, don't change any of the special comment mark-ups!
9
10 #include <iostream>
11 using std::cout; using std::endl;
12 #include <cerrno> // for ::errno
13
14 //[policy_eg_5
15
16 #include <boost/math/special_functions.hpp>
17 // using boost::math::tgamma; // Would create an ambiguity between
18 // 'double boost::math::tgamma<int>(T)' and
19 // 'double 'anonymous-namespace'::tgamma<int>(RT)'.
20
21 namespace mymath
22 { // unnamed
23
24 using namespace boost::math::policies;
25
26 typedef policy<
27 domain_error<errno_on_error>,
28 pole_error<errno_on_error>,
29 overflow_error<errno_on_error>,
30 evaluation_error<errno_on_error>
31 > c_policy;
32
33 BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(c_policy)
34
35 /*`
36 So that when we call `mymath::tgamma(z)`, we really end up calling
37 `boost::math::tgamma(z, anonymous-namespace::c_policy())`.
38 */
39
40 } // close unnamed namespace
41
42 int main()
43 {
44 errno = 0;
45 cout << "Result of tgamma(30000) is: "
46 << mymath::tgamma(30000) << endl;
47 // tgamma in unnamed namespace in this translation unit (file) only.
48 cout << "errno = " << errno << endl;
49 cout << "Result of tgamma(-10) is: "
50 << mymath::tgamma(-10) << endl;
51 cout << "errno = " << errno << endl;
52 // Default tgamma policy would throw an exception, and abort.
53 }
54
55 //] //[/policy_eg_5]
56
57 /*
58 Output:
59
60 Result of tgamma(30000) is: 1.#INF
61 errno = 34
62 Result of tgamma(-10) is: 1.#QNAN
63 errno = 33
64
65
66 */