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 bool is_signed = true; 52 static const bool is_integer = false; 53 static const bool is_exact = false; 54 static const int radix = 2; 55 static boost::math::concepts::std_real_concept epsilon() throw(); 56 static boost::math::concepts::std_real_concept round_error() throw(); 57 static const int min_exponent = -125; 58 static const int min_exponent10 = -37; 59 static const int max_exponent = 128; 60 static const int max_exponent10 = 38; 61 static const bool has_infinity = true; 62 static const bool has_quiet_NaN = true; 63 static const bool has_signaling_NaN = true; 64 static const float_denorm_style has_denorm = denorm_absent; 65 static const bool has_denorm_loss = false; 66 static boost::math::concepts::std_real_concept infinity() throw(); 67 static boost::math::concepts::std_real_concept quiet_NaN() throw(); 68 static boost::math::concepts::std_real_concept signaling_NaN() throw(); 69 static boost::math::concepts::std_real_concept denorm_min() throw(); 70 static const bool is_iec559 = true; 71 static const bool is_bounded = false; 72 static const bool is_modulo = false; 73 static const bool traps = false; 74 static const bool tinyness_before = false; 75 static const float_round_style round_style = round_toward_zero; 76 }; 77 } 78 #endif 79 #ifdef EMULATE64 80 namespace std{ 81 template<> 82 struct numeric_limits<boost::math::concepts::std_real_concept> 83 { 84 static const bool is_specialized = true; 85 static boost::math::concepts::std_real_concept min NULL_MACRO() throw(); 86 static boost::math::concepts::std_real_concept max NULL_MACRO() throw(); 87 static const int digits = 53; 88 static const int digits10 = 15; 89 static const bool is_signed = true; 90 static const bool is_integer = false; 91 static const bool is_exact = false; 92 static const int radix = 2; 93 static boost::math::concepts::std_real_concept epsilon() throw(); 94 static boost::math::concepts::std_real_concept round_error() throw(); 95 static const int min_exponent = -1021; 96 static const int min_exponent10 = -307; 97 static const int max_exponent = 1024; 98 static const int max_exponent10 = 308; 99 static const bool has_infinity = true; 100 static const bool has_quiet_NaN = true; 101 static const bool has_signaling_NaN = true; 102 static const float_denorm_style has_denorm = denorm_absent; 103 static const bool has_denorm_loss = false; 104 static boost::math::concepts::std_real_concept infinity() throw(); 105 static boost::math::concepts::std_real_concept quiet_NaN() throw(); 106 static boost::math::concepts::std_real_concept signaling_NaN() throw(); 107 static boost::math::concepts::std_real_concept denorm_min() throw(); 108 static const bool is_iec559 = true; 109 static const bool is_bounded = false; 110 static const bool is_modulo = false; 111 static const bool traps = false; 112 static const bool tinyness_before = false; 113 static const float_round_style round_style = round_toward_zero; 114 }; 115 } 116 #endif 117 #ifdef EMULATE80 118 namespace std{ 119 template<> 120 struct numeric_limits<boost::math::concepts::std_real_concept> 121 { 122 static const bool is_specialized = true; 123 static boost::math::concepts::std_real_concept min NULL_MACRO() throw(); 124 static boost::math::concepts::std_real_concept max NULL_MACRO() throw(); 125 static const int digits = 64; 126 static const int digits10 = 18; 127 static const bool is_signed = true; 128 static const bool is_integer = false; 129 static const bool is_exact = false; 130 static const int radix = 2; 131 static boost::math::concepts::std_real_concept epsilon() throw(); 132 static boost::math::concepts::std_real_concept round_error() throw(); 133 static const int min_exponent = -16381; 134 static const int min_exponent10 = -4931; 135 static const int max_exponent = 16384; 136 static const int max_exponent10 = 4932; 137 static const bool has_infinity = true; 138 static const bool has_quiet_NaN = true; 139 static const bool has_signaling_NaN = true; 140 static const float_denorm_style has_denorm = denorm_absent; 141 static const bool has_denorm_loss = false; 142 static boost::math::concepts::std_real_concept infinity() throw(); 143 static boost::math::concepts::std_real_concept quiet_NaN() throw(); 144 static boost::math::concepts::std_real_concept signaling_NaN() throw(); 145 static boost::math::concepts::std_real_concept denorm_min() throw(); 146 static const bool is_iec559 = true; 147 static const bool is_bounded = false; 148 static const bool is_modulo = false; 149 static const bool traps = false; 150 static const bool tinyness_before = false; 151 static const float_round_style round_style = round_toward_zero; 152 }; 153 } 154 #endif 155 #ifdef EMULATE128 156 namespace std{ 157 template<> 158 struct numeric_limits<boost::math::concepts::std_real_concept> 159 { 160 static const bool is_specialized = true; 161 static boost::math::concepts::std_real_concept min NULL_MACRO() throw(); 162 static boost::math::concepts::std_real_concept max NULL_MACRO() throw(); 163 static const int digits = 113; 164 static const int digits10 = 33; 165 static const bool is_signed = true; 166 static const bool is_integer = false; 167 static const bool is_exact = false; 168 static const int radix = 2; 169 static boost::math::concepts::std_real_concept epsilon() throw(); 170 static boost::math::concepts::std_real_concept round_error() throw(); 171 static const int min_exponent = -16381; 172 static const int min_exponent10 = -4931; 173 static const int max_exponent = 16384; 174 static const int max_exponent10 = 4932; 175 static const bool has_infinity = true; 176 static const bool has_quiet_NaN = true; 177 static const bool has_signaling_NaN = true; 178 static const float_denorm_style has_denorm = denorm_absent; 179 static const bool has_denorm_loss = false; 180 static boost::math::concepts::std_real_concept infinity() throw(); 181 static boost::math::concepts::std_real_concept quiet_NaN() throw(); 182 static boost::math::concepts::std_real_concept signaling_NaN() throw(); 183 static boost::math::concepts::std_real_concept denorm_min() throw(); 184 static const bool is_iec559 = true; 185 static const bool is_bounded = false; 186 static const bool is_modulo = false; 187 static const bool traps = false; 188 static const bool tinyness_before = false; 189 static const float_round_style round_style = round_toward_zero; 190 }; 191 } 192 #endif 193 194 195 main(int argc,char * [])196int main(int argc, char*[]) 197 { 198 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS 199 if(argc > 1000) 200 instantiate(boost::math::concepts::std_real_concept(0)); 201 #endif 202 } 203 204