
On Fri, May 6, 2011 at 2:07 PM, Lorenzo Caminiti <lorcaminiti@gmail.com> wrote:
On Fri, May 6, 2011 at 1:32 PM, Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung@gmail.com> wrote:
Would "const bind(int)& x" work?
It think yes :) I should be able to support the syntax (also with optional leading const and optional &): bind& x // deduced type (with Boost.Typeof) bind(int)& x // specify type (no Boost.Typeof) More in general "[const] bind [(type)] [&] name" where "[t]" indicates that token t is optional. The basic internal preprocessor tools for that should be: #include <boost/local/aux_/preprocessor/keyword/bind.hpp> #include <boost/preprocessor.hpp> #include <boost/preprocessor/detail/is_unary.hpp> #define IS_BIND_TYPED_(tokens) \ BOOST_PP_IS_UNARY(BOOST_LOCAL_AUX_PP_KEYWORD_BIND_REMOVE_FRONT(tokens)) #define IS_BIND_TYPED(tokens) \ BOOST_PP_IIF(BOOST_LOCAL_AUX_PP_KEYWORD_IS_BIND_FRONT(tokens), \ IS_BIND_TYPED_ \ , \ 0 BOOST_PP_TUPLE_EAT(1) \ )(tokens) #define BIND_TYPED_EXPR_bind(type) \ type #define BIND_TYPED_EXPR_(tokens) \ BOOST_PP_CAT(BIND_TYPED_EXPR_, tokens) #define BIND_TYPED_EXPR(tokens) \ BOOST_PP_IIF(IS_BIND_TYPED(tokens), \ BIND_TYPED_EXPR_ \ , \ tokens BOOST_PP_TUPLE_EAT(1) \ )(tokens) #define BIND_TYPED_REMOVE_FRONT_bind(tokens) /* must expand to nothing */ #define BIND_TYPED_REMOVE_FRONT_(tokens) \ BOOST_PP_CAT(BIND_TYPED_REMOVE_FRONT_, tokens) #define BIND_TYPED_REMOVE_FRONT(tokens) \ BOOST_PP_IIF(IS_BIND_TYPED(tokens), \ BIND_TYPED_REMOVE_FRONT_ \ , \ tokens BOOST_PP_TUPLE_EAT(1) \ )(tokens) ----- IS_BIND_TYPED( int& x ) // 0 IS_BIND_TYPED( bind& x ) // 0 IS_BIND_TYPED( bind(double)& x ) // 1 ----- BIND_TYPED_EXPR( int& x ) // int& x BIND_TYPED_EXPR( bind& x ) // bind& x BIND_TYPED_EXPR( bind(double)& x ) // double& x ----- BIND_TYPED_REMOVE_FRONT( int& x ) // int& x BIND_TYPED_REMOVE_FRONT( bind& x ) // bind& x BIND_TYPED_REMOVE_FRONT( bind(double)& x ) // &x ----- -- Lorenzo