Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71106 - in sandbox/local: boost/local/aux_/function_macros/code_ libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-04-07 23:05:29


Author: lcaminiti
Date: 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
New Revision: 71106
URL: http://svn.boost.org/trac/boost/changeset/71106

Log:
Split macros from code_/params.hpp into functor and binding files.
Added:
   sandbox/local/boost/local/aux_/function_macros/code_/bind_this.hpp (contents, props changed)
Removed:
   sandbox/local/boost/local/aux_/function_macros/code_/param.hpp
Text files modified:
   sandbox/local/boost/local/aux_/function_macros/code_/binding.hpp | 15 ++-
   sandbox/local/boost/local/aux_/function_macros/code_/functor.hpp | 172 ++++++++++++++++++++++++++++++++++++---
   sandbox/local/libs/local/example/benchmark_boost_phoenix.00.cpp | 44 ++++++---
   3 files changed, 195 insertions(+), 36 deletions(-)

Added: sandbox/local/boost/local/aux_/function_macros/code_/bind_this.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/local/aux_/function_macros/code_/bind_this.hpp 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+#ifndef BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_HPP_
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_HPP_
+
+#include "../../symbol.hpp"
+#include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
+#include <boost/detail/preprocessor/keyword/this.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+
+// PUBLIC //
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
+ BOOST_PP_CAT(se_this_type, id) // Using ScopeExit prefix `se_...`.
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_NAME \
+ se_this // Using ScopeExit prefix `se_...`.
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_RENAME(param_name) \
+ /* can't use `PP_KEYWORD_IS_THIS_FRONT()` because some `param_name` */ \
+ /* might start with non-alphanumeric symbol `&` (but never for `this`) */ \
+ BOOST_PP_IIF(BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK(param_name), \
+ BOOST_LOCAL_AUX_SYMBOL_THIS_PARAM_NAME \
+ , \
+ param_name \
+ )
+
+#endif // #include guard
+

Modified: sandbox/local/boost/local/aux_/function_macros/code_/binding.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/code_/binding.hpp (original)
+++ sandbox/local/boost/local/aux_/function_macros/code_/binding.hpp 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
@@ -7,7 +7,7 @@
 #ifndef BOOST_LOCAL_AUX_FUNCTION_CODE_BINDING_HPP_
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_BINDING_HPP_
 
-#include "param.hpp"
+#include "bind_this.hpp"
 #include "../../symbol.hpp"
 #include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
 #include "../../preprocessor/sign/params_any_bind.hpp"
@@ -19,23 +19,28 @@
 
 // PRIVATE //
 
+// Adapted from `BOOST_SCOPE_EXIT_AUX_TAG_DECL()`.
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_BINDING_TAG_DECL_(r, id, i, var) \
+ typedef void (*BOOST_SCOPE_EXIT_AUX_TAG(id,i))(int \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_RENAME(var));
+
 // Adapted from `BOOST_SCOPE_EXIT_AUX_IMPL()`.
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_BINDING_WITH_TAGS_SEQ_( \
         all_binds, has_any_bind_this, id, typename_keyword) \
     /* binding tags */ \
     BOOST_PP_EXPR_IIF(has_any_bind_this, \
         BOOST_SCOPE_EXIT_TYPEDEF_TYPEOF_THIS() \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id); \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id); \
     ) \
- BOOST_PP_LIST_FOR_EACH_I(BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TAG_DECL, \
+ BOOST_PP_LIST_FOR_EACH_I(BOOST_LOCAL_AUX_FUNCTION_CODE_BINDING_TAG_DECL_, \
             id, all_binds) \
     BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_CAPTURE_DECL, \
             (id, typename_keyword), all_binds) \
     /* binding class */ \
     struct BOOST_SCOPE_EXIT_AUX_PARAMS_T(id) { \
         BOOST_PP_EXPR_IIF(has_any_bind_this, \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_NAME; \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_NAME; \
         ) \
         BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_DECL, \
                 (id, typename_keyword), all_binds) \

Modified: sandbox/local/boost/local/aux_/function_macros/code_/functor.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/code_/functor.hpp (original)
+++ sandbox/local/boost/local/aux_/function_macros/code_/functor.hpp 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
@@ -7,7 +7,7 @@
 #ifndef BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_HPP_
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_HPP_
 
-#include "param.hpp"
+#include "bind_this.hpp"
 #include "../../abstract_function.hpp"
 #include "../../symbol.hpp"
 #include "../../preprocessor/sign/params_unbind.hpp"
@@ -16,6 +16,8 @@
 #include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
 #include "../../../config.hpp"
 #include "../../../function.hpp"
+#include <boost/detail/preprocessor/keyword/auto.hpp>
+#include <boost/detail/preprocessor/keyword/register.hpp>
 #include <boost/type_traits.hpp>
 #include <boost/preprocessor/punctuation/comma_if.hpp>
 #include <boost/preprocessor/logical/bitand.hpp>
@@ -32,6 +34,140 @@
 
 // PRIVATE //
 
+// Unbind parameters.
+
+// i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_NAME_(i) \
+ /* this must be a generic parameter name because unbind type and name */ \
+ /* are not separate tokens in the macro syntax so name is not available */ \
+ /* separately from its type */ \
+ BOOST_PP_CAT(arg, i)
+
+// i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_TYPE_(i) \
+ /* the parameter type must be accessed using function traits from */ \
+ /* function type because it is not available to the macro syntax */ \
+ /* separately from the parameter name */ \
+ BOOST_PP_CAT(BOOST_PP_CAT(::boost::function_traits< \
+ BOOST_LOCAL_AUX_SYMBOL_FUNCTION_TYPE>::arg, i), _type) \
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_DECL_( \
+ r, typename_keyword, i, param) \
+ BOOST_PP_COMMA_IF(i) \
+ typename_keyword \
+ ::boost::call_traits< \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_TYPE_( \
+ BOOST_PP_INC(i))>::param_type \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_NAME_(BOOST_PP_INC(i))
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_NAME_ENUM_( \
+ r, unused, i, param) \
+ BOOST_PP_COMMA_IF(i) /* enumeration commas */ \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_NAME_(BOOST_PP_INC(i))
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_DECL_( \
+ r, unused, i, param) \
+ BOOST_PP_COMMA_IF(i) \
+ BOOST_DETAIL_PP_KEYWORD_AUTO_REMOVE_BACK( \
+ BOOST_DETAIL_PP_KEYWORD_REGISTER_REMOVE_BACK( \
+ BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_DECL(param) \
+ ) \
+ )
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_DECL_WITH_DEFAULT_( \
+ r, unused, i, param) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_DECL_(z, unused, i, param) \
+ BOOST_PP_IIF(BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_HAS_DEFAULT( \
+ param), \
+ = BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_DEFAULT \
+ , \
+ BOOST_PP_TUPLE_EAT(1) \
+ )(param)
+
+// Bound parameters.
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_TYPE_( \
+ id_typename_offset, i, var) \
+ BOOST_SCOPE_EXIT_AUX_PARAMS_T( \
+ BOOST_PP_TUPLE_ELEM(3, 0, id_typename_offset)):: \
+ BOOST_SCOPE_EXIT_AUX_PARAM_T( \
+ BOOST_PP_TUPLE_ELEM(3, 0, id_typename_offset), \
+ BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(3, 2, id_typename_offset)),\
+ var)
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_VALUE_( \
+ id_offset, i, var) \
+ BOOST_LOCAL_AUX_SYMBOL_BINDS_VARIABLE_NAME-> \
+ BOOST_SCOPE_EXIT_AUX_PARAM( \
+ BOOST_PP_TUPLE_ELEM(2, 0, id_offset), \
+ BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(2, 1, id_offset)), \
+ var).value
+
+// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG_DECL()`.
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
+ r, id_typename_offset, i, var, is_const) \
+ BOOST_PP_TUPLE_ELEM(3, 1, id_typename_offset) /* eventual typename */ \
+ BOOST_PP_EXPR_IF(is_const, \
+ BOOST_PP_IIF( \
+ BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK(var), \
+ ::boost::local::aux::add_pointed_const< /* pointed obj const */ \
+ , \
+ ::boost::add_const< /* outer type const */ \
+ ) \
+ BOOST_PP_TUPLE_ELEM(3, 1, id_typename_offset) /* eventual typename */ \
+ ) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_TYPE_( \
+ id_typename_offset, i, var) \
+ BOOST_PP_EXPR_IF(is_const, >::type) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_RENAME(var)
+
+// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG_DECL()`.
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_( \
+ r, id_typename_offset, i, var, is_const) \
+ BOOST_PP_COMMA_IF(i) /* enumeration commas */ \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
+ r, id_typename_offset, i, var, is_const)
+
+// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG()`.
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_( \
+ r, id_offset, i, var) \
+ BOOST_PP_COMMA_IF(i) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_VALUE_( \
+ id_offset, i, var)
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_BIND_DECL_( \
+ r, id_typename_offset, i, var) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_( \
+ r, id_typename_offset, i, var, 0 /* do not force const */)
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_CONST_BIND_DECL_( \
+ r, id_typename_offset, i, var) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_( \
+ r, id_typename_offset, i, var, 1 /* force const */)
+
+// Typeof type-definitions.
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_TYPEDEF_( \
+ r, id_typename_offset, i, var, is_const) \
+ typedef \
+ /* the type with the special typeof name */ \
+ BOOST_LOCAL_AUX_SYMBOL_TYPEOF_TYPE( \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
+ r, id_typename_offset, i, var, is_const) \
+ ) ; /* end typedef */
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_TYPEDEF_( \
+ r, id_typename_offset, i, var) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_TYPEDEF_( \
+ r, id_typename_offset, i, var, 0 /* do not add const */)
+
+#define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_CONST_TYPEDEF_( \
+ r, id_typename_offset, i, var) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_TYPEDEF_( \
+ r, id_typename_offset, i, var, 1 /* add const */)
+
+// Template parameter function type `F`.
+
 // Expand to the function type `R (A1, ...)`.
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_F_( \
         sign_params, id, has_type, type_name) \
@@ -39,10 +175,12 @@
     BOOST_PP_EXPR_IIF(has_type, (type_name) ) \
     ( \
         BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_DECL, ~, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_DECL_, ~, \
                 BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND(sign_params)) \
     )
 
+// Functor `operator()`.
+
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_CALL_(z, \
         sign_params, \
         unbinds, \
@@ -52,13 +190,13 @@
     BOOST_LOCAL_AUX_SYMBOL_RESULT_TYPE(id) \
     operator()( \
             BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_DECL, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_DECL_, \
                     typename_keyword, unbinds) \
             ) { \
         /* just forward call to member function with local func name */ \
         return BOOST_LOCAL_AUX_SYMBOL_BODY_FUNCTION_NAME( \
             BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_, \
                     (id, 0 /* no offset */), \
                     const_binds) \
             /* pass plain binds */ \
@@ -69,7 +207,7 @@
                 ) \
             ) \
             BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_MAYBECONST_BIND_, \
                     (id \
                     /* offset param index of # of preceeding */ \
                     /* const-bind params (could be 0)*/ \
@@ -89,7 +227,7 @@
             BOOST_PP_EXPR_IIF( \
                     BOOST_PP_BITOR(has_const_bind_this, has_bind_this), \
                 BOOST_LOCAL_AUX_SYMBOL_BINDS_VARIABLE_NAME-> \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_NAME \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_NAME \
             ) \
             /* pass unbind params */ \
             BOOST_PP_COMMA_IF( \
@@ -105,7 +243,7 @@
                 ) \
             ) \
             BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_ARG_NAME_ENUM_, \
                     ~, unbinds) \
         ); \
     }
@@ -140,6 +278,8 @@
             params_unbinds_constbinds_hasconstthis_binds_hasthis_id_typename) \
     )
 
+// Functor class.
+
 // Adapted from `BOOST_SCOPE_EXIT_AUX_IMPL()`.
 #define BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_(sign_params, \
         unbinds, defaults_count, \
@@ -187,12 +327,12 @@
         /* remove const& using type traits) */ \
         /* const bind typeof types */ \
         BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_CONST_TYPEDEF, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_CONST_TYPEDEF_, \
                 (id, typename_keyword, 0 /* no offset */), \
                 const_binds) \
         /* bind typeof types */ \
         BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TYPEDEF, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_TYPEDEF_, \
                 ( id, typename_keyword, \
                   /* offset param index of # of preceeding */ \
                   /* const-bindparams (could be 0)*/ \
@@ -203,14 +343,14 @@
             typedef \
             BOOST_LOCAL_AUX_SYMBOL_TYPEOF_TYPE( \
                 typename_keyword ::boost::local::aux::add_pointed_const< \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
>::type this /* must not use `this_` for TYPEOF_TYPE */ \
             ) ; /* end typedef */ \
         ) \
         BOOST_PP_EXPR_IIF(has_bind_this, \
             typedef \
             BOOST_LOCAL_AUX_SYMBOL_TYPEOF_TYPE( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
                 this /* must not use `this_` for TYPEOF_TYPE */ \
             ) ; /* end typedef */ \
         ) \
@@ -235,7 +375,7 @@
         BOOST_LOCAL_AUX_SYMBOL_BODY_FUNCTION_NAME( \
                 /* const binds */ \
                 BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_CONST_BIND_DECL, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_CONST_BIND_DECL_,\
                         (id, typename_keyword, 0 /* no offset */), \
                         const_binds) \
                 /* plain binds */ \
@@ -246,7 +386,7 @@
                     ) \
                 ) \
                 BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_BIND_DECL, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_BIND_DECL_, \
                         ( id, typename_keyword, \
                           /* offset param index of # of preceeding */ \
                           /* const-bindparams (could be 0)*/ \
@@ -264,11 +404,11 @@
                 ) \
                 BOOST_PP_EXPR_IIF(has_const_bind_this, \
                     typename_keyword ::boost::local::aux::add_pointed_const< \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
>::type BOOST_LOCAL_CONFIG_THIS_PARAM_NAME \
                 ) \
                 BOOST_PP_EXPR_IIF(has_bind_this, \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_BIND_THIS_TYPE(id) \
                     BOOST_LOCAL_CONFIG_THIS_PARAM_NAME \
                 ) \
                 /* unbind params (last because they can have defaults) */ \
@@ -286,7 +426,7 @@
                     ) \
                 ) \
                 BOOST_PP_LIST_FOR_EACH_I( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_DECL_WITH_DEFAULT, \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_FUNCTOR_UNBIND_DECL_WITH_DEFAULT_, \
                         ~, unbinds) \
             ) /* end body function params */ \
             /* const member func so it cannot change obj (reassign member */ \

Deleted: sandbox/local/boost/local/aux_/function_macros/code_/param.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/code_/param.hpp 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
+++ (empty file)
@@ -1,182 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
-// copy at http://www.boost.org/LICENSE_1_0.txt).
-
-#ifndef BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_HPP_
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_HPP_
-
-#include "../../symbol.hpp"
-#include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
-#include "../../type_traits/add_pointed_const.hpp"
-#include <boost/call_traits.hpp>
-#include <boost/detail/preprocessor/keyword/this.hpp>
-#include <boost/detail/preprocessor/keyword/auto.hpp>
-#include <boost/detail/preprocessor/keyword/register.hpp>
-#include <boost/local/aux_/preprocessor/sign/params_unbind.hpp>
-#include <boost/type_traits.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/control/expr_if.hpp>
-#include <boost/preprocessor/control/iif.hpp>
-#include <boost/preprocessor/arithmetic/add.hpp>
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/tuple/elem.hpp>
-#include <boost/preprocessor/tuple/eat.hpp>
-#include <boost/preprocessor/cat.hpp>
-
-// Param named `this`.
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_TYPE(id) \
- BOOST_PP_CAT(se_this_type, id) // Using ScopeExit prefix `se_...`.
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_THIS_NAME \
- se_this // Using ScopeExit prefix `se_...`.
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_RENAME_THIS(param_name) \
- /* can't use `PP_KEYWORD_IS_THIS_FRONT()` because some `param_name` */ \
- /* might start with non-alphanumeric symbol `&` (but never for `this`) */ \
- BOOST_PP_IIF(BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK(param_name), \
- BOOST_LOCAL_AUX_SYMBOL_THIS_PARAM_NAME \
- , \
- param_name \
- )
-
-// Tag param.
-
-// Adapted from `BOOST_SCOPE_EXIT_AUX_TAG_DECL()`.
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TAG_DECL(r, id, i, var) \
- typedef void (*BOOST_SCOPE_EXIT_AUX_TAG(id,i))(int \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_RENAME_THIS(var) );
-
-// Bound param (const and non-const).
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_TYPE( \
- id_typename_offset, i, var) \
- BOOST_SCOPE_EXIT_AUX_PARAMS_T( \
- BOOST_PP_TUPLE_ELEM(3, 0, id_typename_offset)):: \
- BOOST_SCOPE_EXIT_AUX_PARAM_T( \
- BOOST_PP_TUPLE_ELEM(3, 0, id_typename_offset), \
- BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(3, 2, id_typename_offset)),\
- var)
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_VALUE( \
- id_offset, i, var) \
- BOOST_LOCAL_AUX_SYMBOL_BINDS_VARIABLE_NAME-> \
- BOOST_SCOPE_EXIT_AUX_PARAM( \
- BOOST_PP_TUPLE_ELEM(2, 0, id_offset), \
- BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(2, 1, id_offset)), \
- var).value
-
-// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG_DECL()`.
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_( \
- r, id_typename_offset, i, var, is_const) \
- BOOST_PP_TUPLE_ELEM(3, 1, id_typename_offset) /* eventual typename */ \
- BOOST_PP_EXPR_IF(is_const, \
- BOOST_PP_IIF( \
- BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK(var), \
- ::boost::local::aux::add_pointed_const< /* pointed obj const */ \
- , \
- ::boost::add_const< /* outer type const */ \
- ) \
- BOOST_PP_TUPLE_ELEM(3, 1, id_typename_offset) /* eventual typename */ \
- ) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_TYPE( \
- id_typename_offset, i, var) \
- BOOST_PP_EXPR_IF(is_const, >::type) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_RENAME_THIS(var)
-
-// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG_DECL()`.
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_WITH_COMMA_( \
- r, id_typename_offset, i, var, is_const) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_( \
- r, id_typename_offset, i, var, is_const)
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_CONST_BIND_DECL( \
- r, id_typename_offset, i, var) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_WITH_COMMA_( \
- r, id_typename_offset, i, var, 1 /* force const */)
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_BIND_DECL( \
- r, id_typename_offset, i, var) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_WITH_COMMA_( \
- r, id_typename_offset, i, var, 0 /* do not force const */)
-
-// Adapted from `BOOST_SCOPE_EXIT_AUX_ARG()`.
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND( \
- r, id_offset, i, var) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_VALUE( \
- id_offset, i, var)
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TYPEDEF_( \
- r, id_typename_offset, i, var, is_const) \
- typedef \
- /* the type with the special typeof name */ \
- BOOST_LOCAL_AUX_SYMBOL_TYPEOF_TYPE( \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_MAYBECONST_BIND_DECL_( \
- r, id_typename_offset, i, var, is_const) \
- ) ; /* end typedef */
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_CONST_TYPEDEF( \
- r, id_typename_offset, i, var) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TYPEDEF_( \
- r, id_typename_offset, i, var, 1 /* add const */)
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TYPEDEF( \
- r, id_typename_offset, i, var) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_TYPEDEF_( \
- r, id_typename_offset, i, var, 0 /* do not add const */)
-
-// Unbind param.
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_DECL(r, unused, i, param) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_DETAIL_PP_KEYWORD_AUTO_REMOVE_BACK( \
- BOOST_DETAIL_PP_KEYWORD_REGISTER_REMOVE_BACK( \
- BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_DECL(param) \
- ) \
- )
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_DECL_WITH_DEFAULT( \
- r, unused, i, param) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_DECL(z, unused, i, param) \
- BOOST_PP_IIF(BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_HAS_DEFAULT( \
- param), \
- = BOOST_LOCAL_AUX_PP_SIGN_PARAMS_UNBIND_PARAM_DEFAULT \
- , \
- BOOST_PP_TUPLE_EAT(1) \
- )(param)
-
-// i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME_(i) \
- /* this must be a generic parameter name because unbind type and name */ \
- /* are not separate tokens in the macro syntax so name is not available */ \
- /* separately from its type */ \
- BOOST_PP_CAT(arg, i)
-
-// i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_TYPE_(i) \
- /* the parameter type must be accessed using function traits from */ \
- /* function type because it is not available to the macro syntax */ \
- /* separately from the parameter name */ \
- BOOST_PP_CAT(BOOST_PP_CAT(::boost::function_traits< \
- BOOST_LOCAL_AUX_SYMBOL_FUNCTION_TYPE>::arg, i), _type) \
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME( \
- r, unused, i, param) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME_(BOOST_PP_INC(i))
-
-#define BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_DECL( \
- r, typename_keyword, i, param) \
- BOOST_PP_COMMA_IF(i) \
- typename_keyword \
- ::boost::call_traits< \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_TYPE_( \
- BOOST_PP_INC(i))>::param_type \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME_(BOOST_PP_INC(i))
-
-#endif // #include guard
-

Modified: sandbox/local/libs/local/example/benchmark_boost_phoenix.00.cpp
==============================================================================
--- sandbox/local/libs/local/example/benchmark_boost_phoenix.00.cpp (original)
+++ sandbox/local/libs/local/example/benchmark_boost_phoenix.00.cpp 2011-04-07 23:05:27 EDT (Thu, 07 Apr 2011)
@@ -3,36 +3,50 @@
 #include <iostream>
 #include <vector>
 #include <algorithm>
+#include <cassert>
 
-#define N 10000
+#define N 1e4
+#define S N * 1e2
 
-int f() { return -1; }
+template<typename T>
+struct number_interface {
+ virtual T complement(T x) = 0;
+};
+
+template<typename T>
+struct number: number_interface<T> {
+ T complement(T x) { return -x; }
+};
+
+const double& identity(const double& x) { return x; }
 
 int main() {
     using boost::phoenix::let;
- using boost::phoenix::local_names::_f;
- using boost::phoenix::cref;
     using boost::phoenix::ref;
+ using boost::phoenix::cref;
     using boost::phoenix::arg_names::_1;
- using boost::phoenix::val;
+ using boost::phoenix::local_names::_f;
+ using boost::phoenix::local_names::_x;
+ using boost::phoenix::bind;
 
     double sum = 0.0;
- int factor = 10;
-
- struct l {
- double f(const double& x) { return x; }
- } ll;
+ int factor = 1;
+ const double& (*p)(const double&) = &identity;
+ number<double> d;
 
- std::vector<double> v(N * 100);
- std::fill(v.begin(), v.end(), 10);
+ std::vector<double> v(S);
+ std::fill(v.begin(), v.end(), 1.0);
 
     for (size_t n = 0; n < N; ++n) {
- std::for_each(v.begin(), v.end(), (
- ref(sum) += factor * ll.f(1.0 * _1)
- ));
+ std::for_each(v.begin(), v.end(), let(_f = cref(factor), _x = 0.0)[
+ _x = _f * bind(&identity, _1),
+ _x = -bind(&number<double>::complement, d, _x),
+ ref(sum) += bind(p, _x)
+ ]);
     }
 
     std::cout << sum << std::endl;
+ assert(sum == N * S);
     return 0;
 }
 


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