Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70197 - in trunk: boost/phoenix/stdlib libs/phoenix/test/container libs/phoenix/test/stdlib
From: thom.heller_at_[hidden]
Date: 2011-03-19 12:30:50


Author: theller
Date: 2011-03-19 12:30:47 EDT (Sat, 19 Mar 2011)
New Revision: 70197
URL: http://svn.boost.org/trac/boost/changeset/70197

Log:
[phoenix]

        - patch by Daniel James
        - cmath functionality by Steven Watanabe

Added:
   trunk/boost/phoenix/stdlib/
   trunk/boost/phoenix/stdlib/cmath.hpp (contents, props changed)
   trunk/libs/phoenix/test/stdlib/
   trunk/libs/phoenix/test/stdlib/cmath.cpp (contents, props changed)
Text files modified:
   trunk/libs/phoenix/test/container/container_tests.hpp | 3 ++-
   1 files changed, 2 insertions(+), 1 deletions(-)

Added: trunk/boost/phoenix/stdlib/cmath.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/phoenix/stdlib/cmath.hpp 2011-03-19 12:30:47 EDT (Sat, 19 Mar 2011)
@@ -0,0 +1,69 @@
+/*==============================================================================
+ Copyright (c) 2011 Steven Watanabe
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef BOOST_PHOENIX_CMATH_HPP_INCLUDED
+#define BOOST_PHOENIX_CMATH_HPP_INCLUDED
+
+#include <boost/phoenix/core/limits.hpp>
+#include <cmath>
+#include <boost/phoenix/function/adapt_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+
+namespace boost {
+
+#define BOOST_PHOENIX_MATH_FUNCTION(name, n) \
+ namespace phoenix_impl { \
+ struct name ## _impl { \
+ template<class Sig> \
+ struct result; \
+ template<class This, BOOST_PHOENIX_typename_A(n)> \
+ struct result<This(BOOST_PHOENIX_A(n))> \
+ { \
+ typedef \
+ typename proto::detail::uncvref<A0>::type \
+ type; \
+ }; \
+ template<BOOST_PHOENIX_typename_A(n)> \
+ A0 operator()(BOOST_PHOENIX_A_const_ref_a(n)) const { \
+ using namespace std; \
+ return name(BOOST_PHOENIX_a(n)); \
+ } \
+ }; \
+ } \
+ namespace phoenix { \
+ BOOST_PHOENIX_ADAPT_FUNCTION(name, phoenix_impl::name ## _impl, 1) \
+ }
+
+BOOST_PHOENIX_MATH_FUNCTION(acos, 1)
+BOOST_PHOENIX_MATH_FUNCTION(asin, 1)
+BOOST_PHOENIX_MATH_FUNCTION(atan, 1)
+BOOST_PHOENIX_MATH_FUNCTION(atan2, 2)
+BOOST_PHOENIX_MATH_FUNCTION(ceil, 1)
+BOOST_PHOENIX_MATH_FUNCTION(cos, 1)
+BOOST_PHOENIX_MATH_FUNCTION(cosh, 1)
+BOOST_PHOENIX_MATH_FUNCTION(exp, 1)
+BOOST_PHOENIX_MATH_FUNCTION(fabs, 1)
+BOOST_PHOENIX_MATH_FUNCTION(floor, 1)
+BOOST_PHOENIX_MATH_FUNCTION(fmod, 2)
+BOOST_PHOENIX_MATH_FUNCTION(frexp, 2)
+BOOST_PHOENIX_MATH_FUNCTION(ldexp, 2)
+BOOST_PHOENIX_MATH_FUNCTION(log, 1)
+BOOST_PHOENIX_MATH_FUNCTION(log10, 1)
+BOOST_PHOENIX_MATH_FUNCTION(modf, 2)
+BOOST_PHOENIX_MATH_FUNCTION(pow, 2)
+BOOST_PHOENIX_MATH_FUNCTION(sin, 1)
+BOOST_PHOENIX_MATH_FUNCTION(sinh, 1)
+BOOST_PHOENIX_MATH_FUNCTION(sqrt, 1)
+BOOST_PHOENIX_MATH_FUNCTION(tan, 1)
+BOOST_PHOENIX_MATH_FUNCTION(tanh, 1)
+
+#undef BOOST_PHOENIX_MATH_FUNCTION
+
+}
+
+#endif

Modified: trunk/libs/phoenix/test/container/container_tests.hpp
==============================================================================
--- trunk/libs/phoenix/test/container/container_tests.hpp (original)
+++ trunk/libs/phoenix/test/container/container_tests.hpp 2011-03-19 12:30:47 EDT (Sat, 19 Mar 2011)
@@ -459,12 +459,13 @@
 
     Multimap::value_type const value = *c.begin();
     Multimap::iterator c_begin = c.begin();
+ std::size_t old_size = c.size();
     // wrapper for
     // iterator insert(iterator where, const value_type& val);
     Multimap::iterator it =
         phx::insert(arg1, arg2, arg3)(c, c_begin, value);
 
- if (test(it != c.begin())) {
+ if (test(*it != value || c.size() != old_size + 1)) {
         cerr << "Failed " << typeid(Multimap).name()
        << " test_multimap_insert 1\n";
         return;

Added: trunk/libs/phoenix/test/stdlib/cmath.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/phoenix/test/stdlib/cmath.cpp 2011-03-19 12:30:47 EDT (Sat, 19 Mar 2011)
@@ -0,0 +1,16 @@
+#include <cmath>
+#include <boost/function.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/stdlib/cmath.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ double eps = 0.000001;
+ using namespace boost::phoenix::arg_names;
+ boost::function<bool(double, double)> f = fabs(_1 - _2) < eps;
+
+ BOOST_TEST(f(0.0, 0 * eps));
+ BOOST_TEST(!f(0.0, eps));
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk