1 //  Copyright John Maddock 2006.
2 //  Use, modification and distribution are subject to the
3 //  Boost Software License, Version 1.0. (See accompanying file
4 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
7 
8 #include "poison.hpp"
9 
10 #include <boost/math/concepts/std_real_concept.hpp>
11 #include <boost/math/concepts/distributions.hpp>
12 
13 #include "instantiate.hpp"
14 
15 //
16 // The purpose of this test is to verify that our code compiles
17 // cleanly with a type whose std lib functions are in namespace
18 // std and can *not* be found by ADL.  This verifies that we're
19 // not finding std lib functions that are in the global namespace
20 // for example calling ::pow(double) rather than std::pow(long double).
21 // This is a silent error that does the wrong thing at runtime, and
22 // of course we can't call std::pow() directly because we want
23 // the functions to be found by ADL when that's appropriate.
24 //
25 // Furthermore our code does different things internally depending
26 // on numeric_limits<>::digits, so there are some macros that can
27 // be defined that cause our concept-archetype to emulate various
28 // floating point types:
29 //
30 // EMULATE32: 32-bit float
31 // EMULATE64: 64-bit double
32 // EMULATE80: 80-bit long double
33 // EMULATE128: 128-bit long double
34 //
35 // In order to ensure total code coverage this file must be
36 // compiled with each of the above macros in turn, and then
37 // without any of the above as well!
38 //
39 
40 #define NULL_MACRO /**/
41 #ifdef EMULATE32
42 namespace std{
43 template<>
44 struct numeric_limits<boost::math::concepts::std_real_concept>
45 {
46    static const bool is_specialized = true;
47    static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
48    static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
49    static const int digits = 24;
50    static const int digits10 = 6;
51    static const int max_digits10 = 9;
52    static const bool is_signed = true;
53    static const bool is_integer = false;
54    static const bool is_exact = false;
55    static const int radix = 2;
56    static boost::math::concepts::std_real_concept epsilon() throw();
57    static boost::math::concepts::std_real_concept round_error() throw();
58    static const int min_exponent = -125;
59    static const int min_exponent10 = -37;
60    static const int max_exponent = 128;
61    static const int max_exponent10 = 38;
62    static const bool has_infinity = true;
63    static const bool has_quiet_NaN = true;
64    static const bool has_signaling_NaN = true;
65    static const float_denorm_style has_denorm = denorm_absent;
66    static const bool has_denorm_loss = false;
67    static boost::math::concepts::std_real_concept infinity() throw();
68    static boost::math::concepts::std_real_concept quiet_NaN() throw();
69    static boost::math::concepts::std_real_concept signaling_NaN() throw();
70    static boost::math::concepts::std_real_concept denorm_min() throw();
71    static const bool is_iec559 = true;
72    static const bool is_bounded = false;
73    static const bool is_modulo = false;
74    static const bool traps = false;
75    static const bool tinyness_before = false;
76    static const float_round_style round_style = round_toward_zero;
77 };
78 }
79 #endif
80 #ifdef EMULATE64
81 namespace std{
82 template<>
83 struct numeric_limits<boost::math::concepts::std_real_concept>
84 {
85    static const bool is_specialized = true;
86    static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
87    static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
88    static const int digits = 53;
89    static const int digits10 = 15;
90    static const int max_digits10 = 17;
91    static const bool is_signed = true;
92    static const bool is_integer = false;
93    static const bool is_exact = false;
94    static const int radix = 2;
95    static boost::math::concepts::std_real_concept epsilon() throw();
96    static boost::math::concepts::std_real_concept round_error() throw();
97    static const int min_exponent = -1021;
98    static const int min_exponent10 = -307;
99    static const int max_exponent = 1024;
100    static const int max_exponent10 = 308;
101    static const bool has_infinity = true;
102    static const bool has_quiet_NaN = true;
103    static const bool has_signaling_NaN = true;
104    static const float_denorm_style has_denorm = denorm_absent;
105    static const bool has_denorm_loss = false;
106    static boost::math::concepts::std_real_concept infinity() throw();
107    static boost::math::concepts::std_real_concept quiet_NaN() throw();
108    static boost::math::concepts::std_real_concept signaling_NaN() throw();
109    static boost::math::concepts::std_real_concept denorm_min() throw();
110    static const bool is_iec559 = true;
111    static const bool is_bounded = false;
112    static const bool is_modulo = false;
113    static const bool traps = false;
114    static const bool tinyness_before = false;
115    static const float_round_style round_style = round_toward_zero;
116 };
117 }
118 #endif
119 #ifdef EMULATE80
120 namespace std{
121 template<>
122 struct numeric_limits<boost::math::concepts::std_real_concept>
123 {
124    static const bool is_specialized = true;
125    static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
126    static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
127    static const int digits = 64;
128    static const int digits10 = 18;
129    static const int max_digits10 = 22;
130    static const bool is_signed = true;
131    static const bool is_integer = false;
132    static const bool is_exact = false;
133    static const int radix = 2;
134    static boost::math::concepts::std_real_concept epsilon() throw();
135    static boost::math::concepts::std_real_concept round_error() throw();
136    static const int min_exponent = -16381;
137    static const int min_exponent10 = -4931;
138    static const int max_exponent = 16384;
139    static const int max_exponent10 = 4932;
140    static const bool has_infinity = true;
141    static const bool has_quiet_NaN = true;
142    static const bool has_signaling_NaN = true;
143    static const float_denorm_style has_denorm = denorm_absent;
144    static const bool has_denorm_loss = false;
145    static boost::math::concepts::std_real_concept infinity() throw();
146    static boost::math::concepts::std_real_concept quiet_NaN() throw();
147    static boost::math::concepts::std_real_concept signaling_NaN() throw();
148    static boost::math::concepts::std_real_concept denorm_min() throw();
149    static const bool is_iec559 = true;
150    static const bool is_bounded = false;
151    static const bool is_modulo = false;
152    static const bool traps = false;
153    static const bool tinyness_before = false;
154    static const float_round_style round_style = round_toward_zero;
155 };
156 }
157 #endif
158 #ifdef EMULATE128
159 namespace std{
160 template<>
161 struct numeric_limits<boost::math::concepts::std_real_concept>
162 {
163    static const bool is_specialized = true;
164    static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
165    static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
166    static const int digits = 113;
167    static const int digits10 = 33;
168    static const int max_digits10 = 37;
169    static const bool is_signed = true;
170    static const bool is_integer = false;
171    static const bool is_exact = false;
172    static const int radix = 2;
173    static boost::math::concepts::std_real_concept epsilon() throw();
174    static boost::math::concepts::std_real_concept round_error() throw();
175    static const int min_exponent = -16381;
176    static const int min_exponent10 = -4931;
177    static const int max_exponent = 16384;
178    static const int max_exponent10 = 4932;
179    static const bool has_infinity = true;
180    static const bool has_quiet_NaN = true;
181    static const bool has_signaling_NaN = true;
182    static const float_denorm_style has_denorm = denorm_absent;
183    static const bool has_denorm_loss = false;
184    static boost::math::concepts::std_real_concept infinity() throw();
185    static boost::math::concepts::std_real_concept quiet_NaN() throw();
186    static boost::math::concepts::std_real_concept signaling_NaN() throw();
187    static boost::math::concepts::std_real_concept denorm_min() throw();
188    static const bool is_iec559 = true;
189    static const bool is_bounded = false;
190    static const bool is_modulo = false;
191    static const bool traps = false;
192    static const bool tinyness_before = false;
193    static const float_round_style round_style = round_toward_zero;
194 };
195 }
196 #endif
197 
198 
199 
main(int argc,char * [])200 int main(int argc, char*[])
201 {
202 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
203    if(argc > 1000)
204       instantiate(boost::math::concepts::std_real_concept(0));
205 #endif
206 }
207 
208