cmath.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*==============================================================================
  2. Copyright (c) 2011 Steven Watanabe
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_PHOENIX_CMATH_HPP_INCLUDED
  7. #define BOOST_PHOENIX_CMATH_HPP_INCLUDED
  8. #include <boost/phoenix/core/limits.hpp>
  9. #include <cmath>
  10. #include <boost/phoenix/function/adapt_callable.hpp>
  11. #include <boost/type_traits/remove_reference.hpp>
  12. #include <boost/type_traits/remove_cv.hpp>
  13. namespace boost {
  14. #define BOOST_PHOENIX_MATH_FUNCTION(name, n) \
  15. namespace phoenix_impl { \
  16. struct name ## _impl { \
  17. template<class Sig> \
  18. struct result; \
  19. template<class This, BOOST_PHOENIX_typename_A(n)> \
  20. struct result<This(BOOST_PHOENIX_A(n))> \
  21. { \
  22. typedef \
  23. typename proto::detail::uncvref<A0>::type \
  24. type; \
  25. }; \
  26. template<BOOST_PHOENIX_typename_A(n)> \
  27. A0 operator()(BOOST_PHOENIX_A_const_ref_a(n)) const { \
  28. using namespace std; \
  29. return name(BOOST_PHOENIX_a(n)); \
  30. } \
  31. }; \
  32. } \
  33. namespace phoenix { \
  34. BOOST_PHOENIX_ADAPT_CALLABLE(name, phoenix_impl::name ## _impl, 1) \
  35. }
  36. BOOST_PHOENIX_MATH_FUNCTION(acos, 1)
  37. BOOST_PHOENIX_MATH_FUNCTION(asin, 1)
  38. BOOST_PHOENIX_MATH_FUNCTION(atan, 1)
  39. BOOST_PHOENIX_MATH_FUNCTION(atan2, 2)
  40. BOOST_PHOENIX_MATH_FUNCTION(ceil, 1)
  41. BOOST_PHOENIX_MATH_FUNCTION(cos, 1)
  42. BOOST_PHOENIX_MATH_FUNCTION(cosh, 1)
  43. BOOST_PHOENIX_MATH_FUNCTION(exp, 1)
  44. BOOST_PHOENIX_MATH_FUNCTION(fabs, 1)
  45. BOOST_PHOENIX_MATH_FUNCTION(floor, 1)
  46. BOOST_PHOENIX_MATH_FUNCTION(fmod, 2)
  47. BOOST_PHOENIX_MATH_FUNCTION(frexp, 2)
  48. BOOST_PHOENIX_MATH_FUNCTION(ldexp, 2)
  49. BOOST_PHOENIX_MATH_FUNCTION(log, 1)
  50. BOOST_PHOENIX_MATH_FUNCTION(log10, 1)
  51. BOOST_PHOENIX_MATH_FUNCTION(modf, 2)
  52. BOOST_PHOENIX_MATH_FUNCTION(pow, 2)
  53. BOOST_PHOENIX_MATH_FUNCTION(sin, 1)
  54. BOOST_PHOENIX_MATH_FUNCTION(sinh, 1)
  55. BOOST_PHOENIX_MATH_FUNCTION(sqrt, 1)
  56. BOOST_PHOENIX_MATH_FUNCTION(tan, 1)
  57. BOOST_PHOENIX_MATH_FUNCTION(tanh, 1)
  58. #undef BOOST_PHOENIX_MATH_FUNCTION
  59. }
  60. #endif