Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:14

0001 
0002 // Copyright (C) 2009-2012 Lorenzo Caminiti
0003 // Distributed under the Boost Software License, Version 1.0
0004 // (see accompanying file LICENSE_1_0.txt or a copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 // Home at http://www.boost.org/libs/local_function
0007 
0008 #ifndef BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_HPP_
0009 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_HPP_
0010 
0011 #include <boost/local_function/config.hpp>
0012 #include <boost/local_function/aux_/symbol.hpp>
0013 #include <boost/local_function/aux_/function.hpp>
0014 #include <boost/local_function/aux_/add_pointed_const.hpp>
0015 #include <boost/local_function/aux_/member.hpp>
0016 #include <boost/local_function/aux_/nobind.hpp>
0017 #include <boost/local_function/aux_/macro/decl.hpp>
0018 #include <boost/local_function/aux_/macro/typeof.hpp>
0019 #include <boost/local_function/aux_/macro/code_/result.hpp>
0020 #include <boost/local_function/aux_/macro/code_/bind.hpp>
0021 #include <boost/local_function/aux_/preprocessor/traits/decl_params.hpp>
0022 #include <boost/local_function/aux_/preprocessor/traits/decl_binds.hpp>
0023 #include <boost/local_function/aux_/preprocessor/traits/decl_const_binds.hpp>
0024 #include <boost/local_function/detail/preprocessor/keyword/auto.hpp>
0025 #include <boost/local_function/detail/preprocessor/keyword/register.hpp>
0026 #include <boost/local_function/detail/preprocessor/keyword/thisunderscore.hpp>
0027 #include <boost/utility/identity_type.hpp>
0028 #include <boost/scope_exit.hpp>
0029 #include <boost/type_traits/add_const.hpp>
0030 #include <boost/preprocessor/cat.hpp>
0031 #include <boost/preprocessor/punctuation/comma_if.hpp>
0032 #include <boost/preprocessor/control/expr_iif.hpp>
0033 #include <boost/preprocessor/control/iif.hpp>
0034 #include <boost/preprocessor/facilities/expand.hpp>
0035 #include <boost/preprocessor/facilities/is_empty.hpp>
0036 #include <boost/preprocessor/facilities/empty.hpp>
0037 #include <boost/preprocessor/facilities/identity.hpp>
0038 #include <boost/preprocessor/repetition/enum.hpp>
0039 #include <boost/preprocessor/repetition/repeat.hpp>
0040 #include <boost/preprocessor/arithmetic/inc.hpp>
0041 #include <boost/preprocessor/arithmetic/sub.hpp>
0042 #include <boost/preprocessor/arithmetic/add.hpp>
0043 #include <boost/preprocessor/logical/bitor.hpp>
0044 #include <boost/preprocessor/logical/bitand.hpp>
0045 #include <boost/preprocessor/logical/compl.hpp>
0046 #include <boost/preprocessor/tuple/elem.hpp>
0047 #include <boost/preprocessor/tuple/eat.hpp>
0048 #include <boost/preprocessor/tuple/rem.hpp>
0049 #include <boost/preprocessor/list/adt.hpp>
0050 #include <boost/preprocessor/list/size.hpp>
0051 #include <boost/preprocessor/list/for_each_i.hpp>
0052 #include <boost/preprocessor/list/first_n.hpp>
0053 
0054 // PRIVATE //
0055 
0056 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id) \
0057     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (functor)(id) )
0058 
0059 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ \
0060     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (function_type) )
0061 
0062 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BODY_FUNC_ \
0063     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (body) )
0064 
0065 // Unbind parameters.
0066 
0067 // i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
0068 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_(i) \
0069     /* this must be a generic parameter name because type and name */ \
0070     /* are not separate tokens in the macro syntax so name is not available */ \
0071     /* separately from its type */ \
0072     BOOST_PP_CAT(arg, i)
0073 
0074 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_ENUM_( \
0075         r, unused, i, param_traits) \
0076     BOOST_PP_COMMA_IF(i) /* enumeration commas */ \
0077     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_(BOOST_PP_INC(i))
0078 
0079 // i: 1 for 1st param, 2 for 2nd, ... (start from 1 not 0).
0080 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_TYPE_(typename01, i) \
0081     /* the parameter type must be accessed using function traits from */ \
0082     /* function type because it is not available to the macro syntax */ \
0083     /* separately from the parameter name */ \
0084     BOOST_PP_EXPR_IIF(typename01, typename) \
0085     ::boost::function_traits< \
0086         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ \
0087     >::BOOST_PP_CAT(BOOST_PP_CAT(arg, i), _type) \
0088 
0089 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_ARG_TYPEDEF_( \
0090         r, typename01, i, param_traits) \
0091     typedef \
0092         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_TYPE_(typename01, \
0093                 BOOST_PP_INC(i)) \
0094         /* name must follow Boost.FunctionTraits arg1_type, arg2_type, ... */ \
0095         BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(i)), _type) \
0096     ;
0097 
0098 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_( \
0099         r, typename01, i, param_traits) \
0100     BOOST_PP_EXPR_IIF(typename01, typename) \
0101     ::boost::call_traits< \
0102         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_TYPE_(typename01, \
0103                 BOOST_PP_INC(i)) \
0104     >::param_type \
0105     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_(BOOST_PP_INC(i))
0106 
0107 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_ENUM_( \
0108         r, typename01, i, param_traits) \
0109     BOOST_PP_COMMA_IF(i) \
0110     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_(r, typename01, i, \
0111             param_traits)
0112 
0113 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_PARAM_ARG_DECL_( \
0114         r, typename01, i, param_traits) \
0115     , BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_(r, typename01, i, \
0116             param_traits)
0117 
0118 // Precondition: !EMPTY(DEFAULT(param_traits))
0119 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_DEFAULT_ASSIGNMENT_( \
0120         param_traits) \
0121     = BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_DEFAULT_REMOVE_FRONT( \
0122             BOOST_LOCAL_FUNCTION_AUX_PP_PARAM_TRAITS_DEFAULT(param_traits))
0123 
0124 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_DECL_ENUM_( \
0125         r, default01, i, param_traits) \
0126     BOOST_PP_COMMA_IF(i) \
0127     BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_AUTO_REMOVE_BACK( \
0128     BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_REGISTER_REMOVE_BACK( \
0129         BOOST_LOCAL_FUNCTION_AUX_PP_PARAM_TRAITS_DECL(param_traits) \
0130     )) \
0131     BOOST_PP_IIF(BOOST_PP_COMPL(default01), \
0132         BOOST_PP_TUPLE_EAT(1) /* without default */ \
0133     , BOOST_PP_IIF(BOOST_PP_IS_EMPTY( \
0134             BOOST_LOCAL_FUNCTION_AUX_PP_PARAM_TRAITS_DEFAULT(param_traits)), \
0135         BOOST_PP_TUPLE_EAT(1) /* has no default */ \
0136     , /* else, with default and has default */ \
0137         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_DEFAULT_ASSIGNMENT_ \
0138     ))(param_traits)
0139 
0140 // Bound parameters.
0141 
0142 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAMS_ \
0143     bind_params /* constructor void* param */
0144 
0145 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_VAR_(i) \
0146     /* named `bind0`, `bind1`, ... */ \
0147     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (bind)(i) )
0148 
0149 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_ \
0150     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (bind_this) )
0151 
0152 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_STATIC_BIND_MEMBER_THIS_( \
0153         id) \
0154     , static_cast< BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id)* >( \
0155             object)->BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_
0156 
0157 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_TYPE_( \
0158         id, typename01, offset, i, bind_var_without_type) \
0159     BOOST_PP_EXPR_IIF(typename01, typename) \
0160     BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id):: \
0161     BOOST_SCOPE_EXIT_DETAIL_PARAM_T(id, BOOST_PP_ADD(i, offset), \
0162             bind_var_without_type) \
0163 
0164 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_MEMBER_BIND_ENUM_( \
0165         r, offset, i, bind_traits) \
0166     BOOST_PP_COMMA_IF(i) \
0167     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_VAR_( \
0168             BOOST_PP_ADD(offset, i))
0169 
0170 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_TYPE_( \
0171         r, id_typename_offset_const, i, bind_var_without_type) \
0172     /* IMPORTANT: here can't use `PP_KEYWORD_IS_THISUNDERSCORE_FRONT()` */ \
0173     /* because some `param_name` might start with non-alphanumeric symbol */ \
0174     /* `&` (but that is never the case for `this`) */ \
0175     BOOST_PP_IIF(BOOST_PP_COMPL(BOOST_PP_TUPLE_ELEM(4, 3, \
0176             id_typename_offset_const)), \
0177         BOOST_PP_EMPTY \
0178     , BOOST_PP_IIF( \
0179             BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_THISUNDERSCORE_BACK( \
0180                     bind_var_without_type), \
0181         /* pointed obj const */ \
0182         BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(4, 1, id_typename_offset_const), \
0183             typename \
0184         ) \
0185         BOOST_PP_IDENTITY( ::boost::local_function::aux::add_pointed_const< ) \
0186     , \
0187         BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(4, 1, id_typename_offset_const), \
0188             typename \
0189         ) \
0190         BOOST_PP_IDENTITY( ::boost::add_const< ) /* outer type const */ \
0191     ))() \
0192     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_TYPE_( \
0193             BOOST_PP_TUPLE_ELEM(4, 0, id_typename_offset_const), \
0194             BOOST_PP_TUPLE_ELEM(4, 1, id_typename_offset_const), \
0195             BOOST_PP_TUPLE_ELEM(4, 2, id_typename_offset_const), \
0196             i, bind_var_without_type) \
0197     BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(4, 3, id_typename_offset_const), \
0198         >::type \
0199     )
0200 
0201 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
0202         r, id_typename_offset_const, i, bind_var_without_type) \
0203     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_TYPE_( \
0204             r, id_typename_offset_const, i, bind_var_without_type) \
0205     BOOST_PP_IIF( \
0206             BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_THISUNDERSCORE_BACK( \
0207                     BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0208                             bind_var_without_type)), \
0209         this_ BOOST_PP_TUPLE_EAT(1) \
0210     , \
0211         BOOST_PP_TUPLE_REM(1) \
0212     )(bind_var_without_type)
0213 
0214 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_TYPE_( \
0215         r, id_typename_offset_const, i, bind_traits) \
0216     , BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_TYPE_( \
0217             r, id_typename_offset_const, i, \
0218             BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0219                     bind_traits))
0220 
0221 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_( \
0222         offset, i) \
0223     BOOST_PP_CAT(bind, BOOST_PP_ADD(offset, i))
0224 
0225 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_ENUM_( \
0226         r, offset, i, bind_traits) \
0227     BOOST_PP_COMMA_IF(i) \
0228     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_(offset, i)
0229 
0230 #define \
0231 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_PARAM_DECL_( \
0232         r, id_typename_offset_const, i, bind_traits) \
0233     , BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_TYPE_( \
0234             r, id_typename_offset_const, i, \
0235             BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0236                     bind_traits)) & \
0237       BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_( \
0238             BOOST_PP_TUPLE_ELEM(4, 2, id_typename_offset_const), i)
0239 
0240 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_TYPE_( \
0241         id, typename01) \
0242     , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01)
0243       
0244 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_ \
0245     bind_this
0246 
0247 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_PARAM_DECL_( \
0248         id, typename01) \
0249     , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) & \
0250       BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_
0251 
0252 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_(z, n, unused) \
0253     , ::boost::local_function::aux::nobind
0254 
0255 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_TYPE_(z, n, unused) \
0256     , ::boost::local_function::aux::nobind_t
0257 
0258 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_PARAM_DECL_( \
0259         z, n, unused) \
0260     , ::boost::local_function::aux::nobind_t & \
0261     /* param name not needed here because no bind param not used */
0262 
0263 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_( \
0264         r, id_typename_offset_const, i, bind_traits) \
0265     BOOST_PP_COMMA_IF(i) /* enumeration commas */ \
0266     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
0267             r, id_typename_offset_const, i, \
0268             BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0269                     bind_traits))
0270 
0271 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_DECL_( \
0272         r, id_typename_offset_const, i, bind_traits) \
0273     BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(4, 1, id_typename_offset_const), \
0274         typename \
0275     ) \
0276     ::boost::local_function::aux::member_type< \
0277         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_TYPE_( \
0278                 r, id_typename_offset_const, i, bind_var_without_type) \
0279     >::reference \
0280     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_VAR_( \
0281             BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(4, 2, \
0282                     id_typename_offset_const))) \
0283     ; /* end member variable declaration */
0284 
0285 #define \
0286 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_STATIC_BIND_MEMBER_( \
0287         r, id_typename_offset_const, i, bind_traits) \
0288     , static_cast< BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_( \
0289             BOOST_PP_TUPLE_ELEM(4, 0, id_typename_offset_const))* >(object)-> \
0290       BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_VAR_( \
0291             BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(4, 2, \
0292             id_typename_offset_const)))
0293 
0294 #define \
0295 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_INIT_ENUM_( \
0296         r, id_offset, i, bind_traits) \
0297     BOOST_PP_COMMA_IF(i) \
0298     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_VAR_( \
0299             BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(2, 1, id_offset))) \
0300     ( /* member variable initialization */ \
0301         static_cast< \
0302             BOOST_SCOPE_EXIT_DETAIL_PARAMS_T( \
0303                     BOOST_PP_TUPLE_ELEM(2, 0, id_offset))* \
0304         >(BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAMS_)-> \
0305         BOOST_SCOPE_EXIT_DETAIL_PARAM( \
0306               BOOST_PP_TUPLE_ELEM(2, 0, id_offset) \
0307             , BOOST_PP_ADD(i, BOOST_PP_TUPLE_ELEM(2, 1, id_offset)) \
0308             , BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0309                     bind_traits) \
0310         ).value \
0311     )
0312 
0313 // Typeof type-definitions.
0314 
0315 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_TYPEDEF_( \
0316         r, id_typename_offset_const, i, bind_traits) \
0317     typedef /* the type with the special typeof name */ \
0318         BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE( \
0319             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_( \
0320                     r, id_typename_offset_const, i, \
0321                     BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
0322                             bind_traits)) \
0323         ) \
0324     ; /* end typedef */
0325 
0326 // Expand to the function type `R (A1, ...)`.
0327 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_( \
0328         id, typename01, decl_traits, has_type, function_type) \
0329     BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
0330     BOOST_PP_EXPR_IIF(has_type, (function_type) ) \
0331     ( \
0332         BOOST_PP_LIST_FOR_EACH_I( \
0333                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_DECL_ENUM_, \
0334                 0, /* without defaults */ \
0335                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits)) \
0336     )
0337 
0338 // Functor call operations.
0339 
0340 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_BODY_(id, typename01, \
0341         const_bind_macro, bind_macro, const_bind_this_macro, bind_this_macro, \
0342         param_macro, params, \
0343         const_binds, has_const_bind_this, binds, has_bind_this) \
0344     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BODY_FUNC_( \
0345         BOOST_PP_LIST_FOR_EACH_I(const_bind_macro, \
0346                 0 /* no offset */, const_binds) \
0347         /* pass plain binds */ \
0348         BOOST_PP_COMMA_IF( \
0349             BOOST_PP_BITAND( \
0350                   BOOST_PP_LIST_IS_CONS(const_binds) \
0351                 , BOOST_PP_LIST_IS_CONS(binds) \
0352             ) \
0353         ) \
0354         BOOST_PP_LIST_FOR_EACH_I(bind_macro, \
0355                 /* offset index of # const-binds (could be 0) */ \
0356                 BOOST_PP_LIST_SIZE(const_binds), binds) \
0357         /* pass bind `this` */ \
0358         BOOST_PP_COMMA_IF( \
0359             BOOST_PP_BITAND( \
0360                   BOOST_PP_BITOR( \
0361                       BOOST_PP_LIST_IS_CONS(const_binds) \
0362                     , BOOST_PP_LIST_IS_CONS(binds) \
0363                   ) \
0364                 , BOOST_PP_BITOR(has_const_bind_this, has_bind_this) \
0365             ) \
0366         ) \
0367         BOOST_PP_EXPR_IIF(has_const_bind_this, const_bind_this_macro) \
0368         BOOST_PP_EXPR_IIF(has_bind_this, bind_this_macro) \
0369         /* pass params */ \
0370         BOOST_PP_COMMA_IF( \
0371             BOOST_PP_BITAND( \
0372                   BOOST_PP_BITOR( \
0373                       BOOST_PP_BITOR( \
0374                           BOOST_PP_LIST_IS_CONS(const_binds) \
0375                         , BOOST_PP_LIST_IS_CONS(binds) \
0376                       ) \
0377                     , BOOST_PP_BITOR(has_const_bind_this, has_bind_this) \
0378                   ) \
0379                 , BOOST_PP_LIST_IS_CONS(params) \
0380             ) \
0381         ) \
0382         BOOST_PP_LIST_FOR_EACH_I(param_macro, ~, params) \
0383     )
0384 
0385 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_(z, defaults_n, \
0386         id, typename01, decl_traits, params, \
0387         const_binds, has_const_bind_this, binds, has_bind_this) \
0388     inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
0389     operator()( \
0390         BOOST_PP_LIST_FOR_EACH_I( \
0391                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_ENUM_, \
0392                 typename01, params) \
0393     ) /* cannot be const because of binds (same as for global fctor) */ { \
0394         /* just forward call to member function with local func name */ \
0395         return BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_BODY_(id, typename01,\
0396   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_MEMBER_BIND_ENUM_, \
0397   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_MEMBER_BIND_ENUM_, \
0398                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_, \
0399                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_, \
0400                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_ENUM_, \
0401                 params, const_binds, has_const_bind_this, binds, \
0402                 has_bind_this); \
0403     }
0404 
0405 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_FUNC_( \
0406         z, defaults_n, unused) \
0407     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (call)(defaults_n) )
0408 
0409 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_FUNC_ADDR_( \
0410         z, defaults_n, unused) \
0411     , &BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_FUNC_(z, defaults_n, ~)
0412 
0413 // Precondition: NO_LOCAL_TYPES_AS_TEMPLATE_PARAMS.
0414 #define \
0415 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \
0416         id, typename01, const_binds, has_const_bind_this, binds, has_bind_this)\
0417     BOOST_PP_LIST_FOR_EACH_I( \
0418   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_PARAM_DECL_, \
0419             ( id, typename01, 0 /* no offset */, 1 /* const */ ), const_binds) \
0420     BOOST_PP_LIST_FOR_EACH_I( \
0421   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_PARAM_DECL_, \
0422             /* offset of # of const-binds */ \
0423             ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), 0 /* const */ ),\
0424             binds) \
0425     BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, \
0426             has_const_bind_this), \
0427         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_PARAM_DECL_ \
0428     , \
0429         BOOST_PP_TUPLE_EAT(2) \
0430     )(id, typename01) \
0431     /* fill with nobind_t (if no local-types as tparams) */ \
0432     BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
0433             BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, \
0434                     has_const_bind_this), \
0435                 BOOST_PP_INC \
0436             , \
0437                 BOOST_PP_TUPLE_REM(1) \
0438             )(BOOST_PP_LIST_SIZE(BOOST_PP_LIST_APPEND(const_binds, \
0439                     binds)))), \
0440             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_PARAM_DECL_, ~)
0441 
0442 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_OPERATOR_( \
0443         id, typename01, \
0444         params, const_binds, has_const_bind_this, binds, has_bind_this) \
0445     operator()( \
0446         BOOST_PP_LIST_FOR_EACH_I( \
0447                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_ENUM_, ~, \
0448                 params) \
0449     )
0450 
0451 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_BODY_( \
0452         id, typename01, \
0453         params, const_binds, has_const_bind_this, binds, has_bind_this) \
0454     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_BODY_(id, typename01, \
0455             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_ENUM_, \
0456             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_ENUM_, \
0457             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_, \
0458             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_, \
0459             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_NAME_ENUM_, \
0460             params, const_binds, has_const_bind_this, binds, has_bind_this)
0461 
0462 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_(z, defaults_n, \
0463         id, typename01, decl_traits, params, \
0464         const_binds, has_const_bind_this, binds, has_bind_this) \
0465     inline static BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
0466     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_FUNC_(z, defaults_n, ~)( \
0467         void* object \
0468         BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \
0469             BOOST_PP_TUPLE_EAT(6) \
0470         , \
0471   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_ \
0472         )(id, typename01, \
0473                 const_binds, has_const_bind_this, binds, has_bind_this) \
0474         BOOST_PP_LIST_FOR_EACH_I( \
0475                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_PARAM_ARG_DECL_, \
0476                 typename01, params) \
0477     ) { \
0478         /* run-time: casting object to this class type and forward call to */ \
0479         /* `operator()` (this performs better than doing multiple casting */ \
0480         /* or using a casted object local variable here to call body */ \
0481         /* directly from here without passing via `operator()`) */ \
0482         /* compliance: passing local class type to `static_cast` is fully */ \
0483         /* C++03 compliant because `static_cast` is not a template (even */ \
0484         /* if its syntax resembles a function template call) in fact even */ \
0485         /* in C is legal to cast to a local struct (using C-style casting) */ \
0486         return \
0487             static_cast< \
0488                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id)* \
0489             >(object)-> \
0490             BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\
0491                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_OPERATOR_ \
0492             , \
0493                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_BODY_ \
0494             )(id, typename01, params, \
0495                     const_binds, has_const_bind_this, binds, has_bind_this) \
0496         ; \
0497     }
0498         
0499 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_FOR_DEFAULTS_(z, defaults_n, \
0500         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0501     BOOST_PP_EXPAND( \
0502     BOOST_PP_TUPLE_ELEM(9, 0, \
0503         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0504     ( z, defaults_n \
0505     , BOOST_PP_TUPLE_ELEM(9, 1, /* id */\
0506         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0507     , BOOST_PP_TUPLE_ELEM(9, 2, /* typename01 */ \
0508         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0509     , BOOST_PP_TUPLE_ELEM(9, 3, /* decl_traits */ \
0510         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0511     , BOOST_PP_LIST_FIRST_N( /* remove last n default params */ \
0512           BOOST_PP_SUB(BOOST_PP_LIST_SIZE(BOOST_PP_TUPLE_ELEM(9, 4, \
0513             op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis)),\
0514             defaults_n) \
0515         , BOOST_PP_TUPLE_ELEM(9, 4, \
0516             op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0517       ) \
0518     , BOOST_PP_TUPLE_ELEM(9, 5, /* const_binds */ \
0519         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0520     , BOOST_PP_TUPLE_ELEM(9, 6, /* has_const_bind_this */ \
0521         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0522     , BOOST_PP_TUPLE_ELEM(9, 7, /* binds */ \
0523         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0524     , BOOST_PP_TUPLE_ELEM(9, 8, /* has_bind_this */ \
0525         op_id_typename_decl_params_constbinds_hasconstthis_binds_hasthis) \
0526     ) /* end `op_macro(...)` */ \
0527     ) /* end expand */
0528 
0529 // Functor binds.
0530             
0531 // Precondition: NO_LOCAL_TYPES_AS_TEMPLATE_PARAMS.
0532 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_TYPES_( \
0533         id, typename01, const_binds, has_const_bind_this, binds, has_bind_this)\
0534     BOOST_PP_LIST_FOR_EACH_I( \
0535             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_TYPE_, \
0536             ( id, typename01, 0 /* no offset */, 1 /* const */ ), \
0537             const_binds) \
0538     BOOST_PP_LIST_FOR_EACH_I( \
0539             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_BIND_TYPE_, \
0540             /* offset of # of const-binds */ \
0541             ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), 0 /* const */ ),\
0542             binds) \
0543     BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, \
0544             has_const_bind_this), \
0545         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_TYPE_ \
0546     , \
0547         BOOST_PP_TUPLE_EAT(2) \
0548     )(id, typename01) \
0549     /* fill with nobind_t (if no local-types as tparams) */ \
0550     BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
0551             BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, has_const_bind_this), \
0552                 BOOST_PP_INC \
0553             , \
0554                 BOOST_PP_TUPLE_REM(1) \
0555             )(BOOST_PP_LIST_SIZE(BOOST_PP_LIST_APPEND(const_binds, binds)))), \
0556             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_TYPE_, ~)
0557         
0558 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_TYPEOF_TYPEDEFS_( \
0559         id, typename01, const_binds, has_const_bind_this, binds, has_bind_this)\
0560     /* typeof types -- these types are qualified with extra eventual */ \
0561     /* const and/or & if their variables are bound by const and/or & */ \
0562     /* (this is because it is not possible to strip the eventual & */ \
0563     /* given that the var name is always attached to the & symbol plus */ \
0564     /* programmers can always remove const& using type traits) */ \
0565     /* const bind typeof types */ \
0566     BOOST_PP_LIST_FOR_EACH_I( \
0567             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_TYPEDEF_,\
0568             (id, typename01, 0 /* no offset */, 1 /* const-bind */ ), \
0569             const_binds) \
0570     /* bind typeof types */ \
0571     BOOST_PP_LIST_FOR_EACH_I( \
0572             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_TYPEDEF_, \
0573             /* offset index with # of preceding const-binds (if any) */ \
0574             ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), \
0575               0 /* not const-bind */ ), binds) \
0576     /* const this... */ \
0577     BOOST_PP_EXPR_IIF(has_const_bind_this, \
0578         typedef BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE( \
0579             BOOST_PP_EXPR_IIF(typename01, typename) \
0580             ::boost::local_function::aux::add_pointed_const< \
0581                 BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
0582             >::type \
0583             this_ \
0584         ) ; /* close typedef */ \
0585     ) \
0586     /* ... or, non-const this */ \
0587     BOOST_PP_EXPR_IIF(has_bind_this, \
0588         typedef BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE( \
0589             BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
0590             this_ \
0591         ) ; /* close typedef */ \
0592     )
0593 
0594 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_DECLS_( \
0595         id, typename01, const_binds, has_const_bind_this, binds, has_bind_this)\
0596     /* run-time: it is faster if call `operator()` just accesses member */ \
0597     /* references to the ScopeExit struct instead of accessing the bind */ \
0598     /* struct at each call (these mem refs are init by the constructor) */ \
0599     BOOST_PP_LIST_FOR_EACH_I( /* const bind member references */ \
0600             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_DECL_,\
0601             ( id, typename01, 0 /* no offset */, 1 /* const */ ), \
0602             const_binds) \
0603     BOOST_PP_LIST_FOR_EACH_I( /* bind member references */ \
0604             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_DECL_,\
0605             /* offset index of # of const-binds (could be 0) */ \
0606             ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), \
0607               0 /* no const */ ), binds) \
0608     /* bind this const or not (pointed-const is not added here because */ \
0609     /* this is a reference, it is added to the this_ body param instead */ \
0610     BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(has_bind_this, has_const_bind_this), \
0611         /* this is * so no & */ \
0612         BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
0613             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_ \
0614         ; /* end member variable declaration */ \
0615     )
0616 
0617 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_STATIC_BINDS_( \
0618         id, typename01, \
0619         const_binds, has_const_bind_this, binds, has_bind_this) \
0620     BOOST_PP_LIST_FOR_EACH_I( \
0621   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_STATIC_BIND_MEMBER_, \
0622         ( id, typename01, 0 /* no offset */, 1 /* const */ ), const_binds) \
0623     BOOST_PP_LIST_FOR_EACH_I( \
0624   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_MAYBECONST_STATIC_BIND_MEMBER_, \
0625         /* offset of # of const-binds */ \
0626         ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), 0 /* const */ ), \
0627         binds) \
0628     BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, \
0629             has_const_bind_this), \
0630         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_STATIC_BIND_MEMBER_THIS_ \
0631     , \
0632         BOOST_PP_TUPLE_EAT(1) \
0633     )(id) \
0634     /* fill with nobind_t (if no local-types as tparams) */ \
0635     BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
0636             BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, has_const_bind_this), \
0637                 BOOST_PP_INC \
0638             , \
0639                 BOOST_PP_TUPLE_REM(1) \
0640             )(BOOST_PP_LIST_SIZE(BOOST_PP_LIST_APPEND(const_binds, binds)))), \
0641             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_, ~)
0642 
0643 // Functor inits.
0644         
0645 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MEMBER_INITS_(id, typename01, \
0646         const_binds, has_const_bind_this, binds, has_bind_this) \
0647     BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(BOOST_PP_BITOR(BOOST_PP_BITOR( \
0648             BOOST_PP_LIST_IS_CONS(const_binds), BOOST_PP_LIST_IS_CONS(binds)), \
0649             has_bind_this), has_const_bind_this), \
0650         : \
0651     ) \
0652     /* init const binds */ \
0653     BOOST_PP_LIST_FOR_EACH_I( \
0654   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_INIT_ENUM_, \
0655             ( id, 0 /* no offset */ ), const_binds) \
0656     /* init plain binds */ \
0657     BOOST_PP_COMMA_IF( \
0658         BOOST_PP_BITAND( \
0659               BOOST_PP_LIST_IS_CONS(const_binds) \
0660             , BOOST_PP_LIST_IS_CONS(binds) \
0661         ) \
0662     ) \
0663     BOOST_PP_LIST_FOR_EACH_I( \
0664   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_INIT_ENUM_, \
0665             /* offset index of # of const-binds (could be 0) */ \
0666             ( id, BOOST_PP_LIST_SIZE(const_binds) ), binds) \
0667     /* init `this` bind (const or not) */ \
0668     BOOST_PP_COMMA_IF( \
0669         BOOST_PP_BITAND( \
0670               BOOST_PP_BITOR( \
0671                   BOOST_PP_LIST_IS_CONS(const_binds) \
0672                 , BOOST_PP_LIST_IS_CONS(binds) \
0673               ) \
0674             , BOOST_PP_BITOR(has_const_bind_this, has_bind_this) \
0675         ) \
0676     ) \
0677     BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(has_const_bind_this, has_bind_this), \
0678         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_( \
0679             static_cast< BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id)* >( \
0680                     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAMS_)-> \
0681                     BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_VAR \
0682         ) \
0683     )
0684 
0685 // Functor class.
0686 
0687 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_( \
0688         id, typename01, decl_traits, params, \
0689         default_count, const_binds, has_const_bind_this, binds, has_bind_this) \
0690     typedef class BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id) \
0691     /* run-time: do not use base class to allow for compiler optimizations */ \
0692     { \
0693         /* function type */ \
0694     private: \
0695         typedef \
0696             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_(id, typename01, \
0697                     decl_traits, 1 /* has type */, \
0698                     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_) \
0699         ; \
0700         /* functor type -- this type cannot have ID postfix because it is */ \
0701         /* used the `NAME` macro (this symbol is within functor class so */ \
0702         /* it does not have to have ID postfix), must be public so it */ \
0703         /* can be accessed by `NAME` macro from outside this class */ \
0704     public: \
0705         typedef BOOST_PP_EXPR_IIF(typename01, typename) \
0706             BOOST_IDENTITY_TYPE(( /* IDENTITY for template param comma */ \
0707                 ::boost::local_function::aux::function< \
0708                       BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ \
0709                     , default_count \
0710                     BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\
0711                         BOOST_PP_TUPLE_EAT(6) \
0712                     , \
0713                         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_TYPES_\
0714                     )(id, typename01, const_binds, has_const_bind_this, \
0715                             binds, has_bind_this) \
0716                 > \
0717             )) \
0718             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE \
0719         ; \
0720     private: \
0721         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_TYPEOF_TYPEDEFS_( \
0722                 id, typename01, \
0723                 const_binds, has_const_bind_this, binds, has_bind_this) \
0724     public: \
0725         /* public trait interface following Boost.FunctionTraits names */ \
0726         /* (traits must be defined in both this and the global functor) */ \
0727         enum { arity = ::boost::function_traits< /* can't use static data */ \
0728                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ >::arity }; \
0729         typedef BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
0730                 result_type; \
0731         BOOST_PP_LIST_FOR_EACH_I( \
0732                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_ARG_TYPEDEF_, \
0733                 typename01, params) \
0734         /* constructor */ \
0735         inline explicit BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id)( \
0736                 void* BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAMS_) \
0737             /* NOTE: there is no way to wrap member initializer commas */ \
0738             /* within paren so you must handle these commas manually if */ \
0739             /* expanding this macro within another macro */ \
0740             BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MEMBER_INITS_(id, typename01,\
0741                     const_binds, has_const_bind_this, binds, has_bind_this) \
0742         { /* do nothing */ } \
0743         /* run-time: implement `operator()` (and for all default params) so */ \
0744         /* this obj can be used directly as a functor for C++03 extensions */ \
0745         /* and optimized macros */ \
0746         BOOST_PP_REPEAT( \
0747                 /* PP_INC to handle no dflt (EXPAND for MVSC) */ \
0748                 BOOST_PP_EXPAND(BOOST_PP_INC(default_count)), \
0749                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_FOR_DEFAULTS_,\
0750                 ( BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_, id, typename01 \
0751                 , decl_traits, params, const_binds, has_const_bind_this, binds \
0752                 , has_bind_this ) ) \
0753         /* compliance: trick to pass this local class as a template param */ \
0754         /* on pure C++03 without non C++03 extension */ \
0755         /* performance: this trick introduced _one_ indirect function call */ \
0756         /* via a function pointer that is usually not inlined by compliers */ \
0757         /* thus increasing run-time (also another trick using a base */ \
0758         /* interface class was investigated but virtual calls also cannot */ \
0759         /* inlined plus they require virtual table lookups to the "virtual */ \
0760         /* call trick" measured longer run-times than this "static call */ \
0761         /* trick") */ \
0762         BOOST_PP_REPEAT( \
0763                 /* PP_INC to handle no dflt (EXPAND for MVSC) */ \
0764                 BOOST_PP_EXPAND(BOOST_PP_INC(default_count)), \
0765                 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_FOR_DEFAULTS_,\
0766                 ( BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_, id \
0767                 , typename01, decl_traits, params, const_binds \
0768                 , has_const_bind_this, binds, has_bind_this ) ) \
0769         inline static void BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \
0770               void* object \
0771             , BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE& functor \
0772         ) { \
0773             functor.BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \
0774                     object \
0775                     BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\
0776                         BOOST_PP_TUPLE_EAT(6) \
0777                     , \
0778   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_STATIC_BINDS_ \
0779                     )(id, typename01, const_binds, has_const_bind_this, \
0780                             binds, has_bind_this) \
0781                 BOOST_PP_REPEAT( /* INC to handle no dflt (EXPAND for MVSC) */ \
0782                         BOOST_PP_EXPAND(BOOST_PP_INC(default_count)), \
0783   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_FUNC_ADDR_, \
0784                         ~) \
0785             ); \
0786         } \
0787     private: \
0788         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_DECLS_(id, \
0789                 typename01, const_binds, has_const_bind_this, binds, \
0790                 has_bind_this) \
0791         /* this decl allows for nesting (local functions, etc) as */ \
0792         /* it makes the args variable visible within the body code (which */ \
0793         /* cannot be static); this is for compilation only as the args */ \
0794         /* variable is actually declared by the 1st enclosing local func */ \
0795         boost::scope_exit::detail::undeclared \
0796                 BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR; \
0797         /* body function (unfortunately, cannot be static to allow access */ \
0798         /* to member var with local function name for recursion but doing */ \
0799         /* so also allows the body to misuse `this` instead of `this_`) */ \
0800         inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
0801         BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BODY_FUNC_( \
0802                 /* const binds */ \
0803                 BOOST_PP_LIST_FOR_EACH_I( \
0804   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_, \
0805                         ( id, typename01, 0 /* no offset */, 1 /* const */ ), \
0806                         const_binds) \
0807                 /* plain binds */ \
0808                 BOOST_PP_COMMA_IF( \
0809                     BOOST_PP_BITAND( \
0810                           BOOST_PP_LIST_IS_CONS(const_binds) \
0811                         , BOOST_PP_LIST_IS_CONS(binds) \
0812                     ) \
0813                 ) \
0814                 BOOST_PP_LIST_FOR_EACH_I( \
0815   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_DECL_ENUM_, \
0816                         /* offset index of # of const-binds (could be 0) */ \
0817                         ( id, typename01, BOOST_PP_LIST_SIZE(const_binds), \
0818                           0 /* not const-bind */ ), binds) \
0819                 /* `this` bind */ \
0820                 BOOST_PP_COMMA_IF( \
0821                     BOOST_PP_BITAND( \
0822                           BOOST_PP_BITOR( \
0823                               BOOST_PP_LIST_IS_CONS(const_binds) \
0824                             , BOOST_PP_LIST_IS_CONS(binds) \
0825                           ) \
0826                         , BOOST_PP_BITOR(has_const_bind_this, has_bind_this) \
0827                     ) \
0828                 ) \
0829                 /* const pointer to const object */ \
0830                 BOOST_PP_EXPR_IIF(has_const_bind_this, \
0831                     BOOST_PP_EXPR_IIF(typename01, typename) \
0832                     ::boost::local_function::aux::add_pointed_const< \
0833                         BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, \
0834                                 typename01) \
0835                     >::type \
0836                     const this_ /* special name to access object this */ \
0837                 ) \
0838                 /* const pointer to non-const object */ \
0839                 BOOST_PP_EXPR_IIF(has_bind_this, \
0840                     BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, \
0841                             typename01) \
0842                     const this_ /* special name to access object this */ \
0843                 ) \
0844                 /* params (last because they can have defaults) */ \
0845                 BOOST_PP_COMMA_IF( \
0846                     BOOST_PP_BITAND( \
0847                           BOOST_PP_BITOR( \
0848                               BOOST_PP_BITOR( \
0849                                   BOOST_PP_LIST_IS_CONS(const_binds) \
0850                                 , BOOST_PP_LIST_IS_CONS(binds) \
0851                               ) \
0852                             , BOOST_PP_BITOR(has_const_bind_this, \
0853                                     has_bind_this) \
0854                           ) \
0855                         , BOOST_PP_LIST_IS_CONS(params) \
0856                     ) \
0857                 ) \
0858                 BOOST_PP_LIST_FOR_EACH_I( \
0859   BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_DECL_ENUM_, \
0860                         1 /* with defaults */, params) \
0861             ) /* end body function params */ \
0862             /* cannot be const because recursive functor is non const member */\
0863     /* user local function definition `{ ... }` will follow here */ \
0864     /* `END` macro will close function class decl `};` here */ 
0865 
0866 // PUBLIC //
0867 
0868 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE \
0869     BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (functor_type) )
0870 
0871 #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR(id, typename01, decl_traits) \
0872     BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_(id, typename01, decl_traits \
0873         /* params (might have defaults) */ \
0874         , BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS(decl_traits) \
0875         , BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_PARAMS_DEFAULT_COUNT( \
0876                 decl_traits) \
0877         /* const bind vars (`this` excluded) */ \
0878         , BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BINDS(decl_traits) \
0879         /* if const bind `this` is present */ \
0880         , BOOST_PP_LIST_IS_CONS( \
0881                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_CONST_BIND_THIS_TYPES( \
0882                 decl_traits)) \
0883         /* bind (non-const) vars (`this` excluded) */ \
0884         , BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BINDS(decl_traits) \
0885         /* if (non-const) bind `this` is present */ \
0886         , BOOST_PP_LIST_IS_CONS( \
0887                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_BIND_THIS_TYPES( \
0888                 decl_traits)) \
0889     )
0890 
0891 #endif // #include guard
0892