[MPL] BOOST_MPL_METAFUNCTION_MAX_ARITY in template_arity

I think there's a mismatch in the use of BOOST_MPL_METAFUNCTION_MAX_ARITY. mpl::bind<> and aux::template_arity<> both make use of the BOOST_MPL_METAFUNCTION_MAX_ARITY when generating code. However, bind<> has an additional leading argument which increases it's arity by one. This means template_arity<> will return the wrong arity. This demonstrates the bug: #include <boost/mpl/bind.hpp> #include <boost/mpl/lambda.hpp> using namespace boost::mpl; template<int N, class T> void f() { T x[-1]; } int main() { f< aux::template_arity<bind<int> >::value , bind<int> >(); } With gcc3.3 this results in: arity.cpp: In function `void f() [with int N = 5, T = boost::mpl::bind< int , boost::mpl::void_ , boost::mpl::void_ , boost::mpl::void_ , boost::mpl::void_ , boost::mpl::void_ > ]': Where N should actually be 6. -- Daniel Wallin

Daniel Wallin writes:
I think there's a mismatch in the use of BOOST_MPL_METAFUNCTION_MAX_ARITY.
mpl::bind<> and aux::template_arity<> both make use of the BOOST_MPL_METAFUNCTION_MAX_ARITY when generating code. However, bind<> has an additional leading argument which increases it's arity by one. This means template_arity<> will return the wrong arity.
Daniel, This is already fixed in the new version of the library which I hope to integrate into the main trunk today. Thank you for the report, -- Aleksey Gurtovoy MetaCommunications Engineering
participants (2)
-
Aleksey Gurtovoy
-
Daniel Wallin