Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-21 15:42:37


Author: eric_niebler
Date: 2008-05-21 15:42:36 EDT (Wed, 21 May 2008)
New Revision: 45618
URL: http://svn.boost.org/trac/boost/changeset/45618

Log:
phoenix::bind()
Added:
   branches/proto/v4/boost/phoenix/bind/
   branches/proto/v4/boost/phoenix/bind.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/bind/bind.hpp (contents, props changed)
Text files modified:
   branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp | 48 +++++++++++++++++++++++++++++++++------
   1 files changed, 40 insertions(+), 8 deletions(-)

Added: branches/proto/v4/boost/phoenix/bind.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/bind.hpp 2008-05-21 15:42:36 EDT (Wed, 21 May 2008)
@@ -0,0 +1,13 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ 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_BIND_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_BIND_HPP_EAN_2008_05_21
+
+#include <boost/phoenix/bind/bind.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/bind/bind.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/bind/bind.hpp 2008-05-21 15:42:36 EDT (Wed, 21 May 2008)
@@ -0,0 +1,107 @@
+#ifndef BOOST_PP_IS_ITERATING
+ /*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ 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_BIND_BIND_HPP_EAN_2008_05_21
+ #define BOOST_PHOENIX_BIND_BIND_HPP_EAN_2008_05_21
+
+ #include <boost/preprocessor.hpp>
+ #include <boost/mpl/if.hpp>
+ #include <boost/proto/proto.hpp>
+ #include <boost/phoenix/core/actor.hpp>
+ #include <boost/type_traits/is_member_pointer.hpp>
+
+ namespace boost { namespace phoenix
+ {
+ template<typename Fun>
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , Fun
+ >::type
+ > const
+ bind(Fun const &fun)
+ {
+ return proto::implicit_expr(fun);
+ }
+
+ #define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (1, BOOST_PP_SUB(PHOENIX_LIMIT, 2), <boost/phoenix/bind/bind.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<
+ typename Fun
+ , typename A0
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_PARAMS(N, typename A)
+ >
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , Fun
+ , typename mpl::if_<
+ is_member_pointer<Fun>
+ , A0 &
+ , A0
+ >::type
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_PARAMS(N, A)
+ >::type
+ > const
+ bind(
+ Fun const &fun
+ , A0 &a0
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(N, A, const &a)
+ )
+ {
+ return proto::implicit_expr(fun BOOST_PP_ENUM_TRAILING_PARAMS(N, a));
+ }
+
+ template<
+ typename Fun
+ , typename A0
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_PARAMS(N, typename A)
+ >
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , Fun
+ , typename mpl::if_<
+ is_member_pointer<Fun>
+ , A0 const &
+ , A0
+ >::type
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_PARAMS(N, A)
+ >::type
+ > const
+ bind(
+ Fun const &fun
+ , A0 const &a0
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(N, A, const &a)
+ )
+ {
+ return proto::implicit_expr(fun BOOST_PP_ENUM_TRAILING_PARAMS(N, a));
+ }
+
+ #undef N
+
+#endif

Modified: branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp
==============================================================================
--- branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp (original)
+++ branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp 2008-05-21 15:42:36 EDT (Wed, 21 May 2008)
@@ -26,12 +26,20 @@
 
     struct sqr
     {
- template <typename Arg>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
         {
             typedef Arg type;
         };
 
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ : result<This(Arg)>
+ {};
+
         template <typename Arg>
         Arg operator()(Arg n) const
         {
@@ -41,12 +49,20 @@
 
     struct fact
     {
- template <typename Arg>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
         {
             typedef Arg type;
         };
 
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ : result<This(Arg)>
+ {};
+
         template <typename Arg>
         Arg operator()(Arg n) const
         {
@@ -56,12 +72,20 @@
 
     struct power
     {
- template <typename Arg1, typename Arg2>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1, Arg2)>
         {
             typedef Arg1 type;
         };
 
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1 &, Arg2)>
+ : result<This(Arg1, Arg2)>
+ {};
+
         template <typename Arg1, typename Arg2>
         Arg1 operator()(Arg1 a, Arg2 b) const
         {
@@ -71,12 +95,20 @@
 
     struct add
     {
- template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result<This(Arg1, Arg2, Arg3, Arg4)>
         {
             typedef Arg1 type;
         };
 
+ template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result<This(Arg1 &, Arg2, Arg3, Arg4)>
+ : result<This(Arg1, Arg2, Arg3, Arg4)>
+ {};
+
         template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
         Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const
         {


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