std_real_concept_check.cpp 7.9 KB

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