cmath.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Copyright (c) 2014 John Fletcher
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #include <cmath>
  8. #include <boost/function.hpp>
  9. #include <boost/phoenix/core.hpp>
  10. #include <boost/phoenix/operator.hpp>
  11. #include <boost/phoenix/stl/cmath.hpp>
  12. #include <boost/core/lightweight_test.hpp>
  13. int main()
  14. {
  15. double eps = 0.000001;
  16. using namespace boost::phoenix::arg_names;
  17. boost::function<bool(double, double)> f = boost::phoenix::fabs(_1 - _2) < eps;
  18. double x = boost::phoenix::pow(_1,_2)(2.,2.);
  19. double y = boost::phoenix::atan2(_1,_2)(1.,1.);
  20. double z = boost::phoenix::tan(_1)(y);
  21. BOOST_TEST(f(0.0, 0 * eps));
  22. BOOST_TEST(!f(0.0, eps));
  23. BOOST_TEST(std::fabs(x-4.) < eps );
  24. BOOST_TEST(std::fabs(z-1.) < eps );
  25. return boost::report_errors();
  26. }