Index: template_arity.hpp =================================================================== --- template_arity.hpp (revision 48657) +++ template_arity.hpp (working copy) @@ -64,60 +64,29 @@ namespace boost { namespace mpl { namespace aux { template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag + : arity_tag { - typedef char (&type)[N + 1]; + typedef char (&type)[N + 2]; }; -# define AUX778076_MAX_ARITY_OP(unused, state, i_) \ - ( BOOST_PP_CAT(C,i_) > 0 ? BOOST_PP_CAT(C,i_) : state ) \ -/**/ - -template< - BOOST_MPL_PP_PARAMS(AUX778076_ARITY, BOOST_MPL_AUX_NTTP_DECL(int, C)) - > -struct max_arity +template <> +struct arity_tag<0> { - BOOST_STATIC_CONSTANT(int, value = - BOOST_PP_SEQ_FOLD_LEFT( - AUX778076_MAX_ARITY_OP - , -1 - , BOOST_MPL_PP_RANGE(1, AUX778076_ARITY) - ) - ); + typedef char type; }; -# undef AUX778076_MAX_ARITY_OP - arity_tag<0>::type arity_helper(...); # define BOOST_PP_ITERATION_LIMITS (1, AUX778076_ARITY) # define BOOST_PP_FILENAME_1 # include BOOST_PP_ITERATE() -template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) > -struct template_arity_impl -{ - BOOST_STATIC_CONSTANT(int, value = - sizeof(arity_helper(type_wrapper(),arity_tag())) - 1 - ); -}; - -# define AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION(unused, i_, F) \ - BOOST_PP_COMMA_IF(i_) template_arity_impl::value \ -/**/ - template< typename F > struct template_arity + : mpl::int_< + (sizeof(arity_helper(type_wrapper(), arity_tag())) - 2) + > { - BOOST_STATIC_CONSTANT(int, value = ( - max_arity< BOOST_MPL_PP_REPEAT( - AUX778076_ARITY - , AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION - , F - ) >::value - )); - - typedef mpl::int_ type; }; # undef AUX778076_TEMPLATE_ARITY_IMPL_INVOCATION