when i run the code below i get the following error (boost version 1.46.1-7ubuntu3 running on kubuntu 12.04):
test_param_bug.cpp:34:1: error: wrong number of template arguments (6, should be 5)
/usr/include/boost/parameter/parameters.hpp:714:8: error: provided for ‘template<class PS0, class PS1, class PS2, class PS3, class PS4> struct boost::parameter::parameters’
In file included from test_param_bug.cpp:2:0:
/usr/include/boost/parameter/preprocessor.hpp: In instantiation of ‘boost::parameter::aux::argument_pack<boost_param_params_34func<int> >’:
test_param_bug.cpp:34:1: instantiated from here
/usr/include/boost/parameter/preprocessor.hpp:157:13: error: no type named ‘parameter_spec0’ in ‘struct boost_param_params_34func<int>’
/usr/include/boost/parameter/preprocessor.hpp:158:47: error: no type named ‘parameter_spec0’ in ‘struct boost_param_params_34func<int>’
test_param_bug.cpp:34:1: error: template argument 1 is invalid
test_param_bug.cpp:34:1: error: expected initializer before ‘func’
test_param_bug.cpp:34:1: error: wrong number of template arguments (7, should be 6)
/usr/include/boost/parameter/preprocessor.hpp:148:8: error: provided for ‘template<class Parameters, class A0, class A1, class A2, class A3, class A4> struct boost::parameter::aux::argument_pack’
test_param_bug.cpp:34:1: error: template argument 1 is invalid
test_param_bug.cpp:34:1: error: wrong number of template arguments (7, should be 6)
/usr/include/boost/parameter/preprocessor.hpp:98:8: error: provided for ‘template<class Parameters, class A0, class A1, class A2, class A3, class A4> struct boost::parameter::aux::match’
test_param_bug.cpp: In function ‘int main()’:
test_param_bug.cpp:41:10: error: no matching function for call to ‘func()’
test_param_bug.cpp:41:10: note: candidates are:
...CUT....
it works fine with at most five parameters though. it’d be nice to make this run cause i think it’s a handy feature. is this a well known limitation or am i not using it correctly?
BOOST_PARAMETER_FUNCTION(
(void),
func,
tag,
(optional
(param1, (int), 0)
(param2, (int), 0)
(param3, (int), 0)
(param4, (int), 0)
(param5, (int), 0)
(param6, (int), 0) //<- won't work. too many arguments?
)
)
{
}
The max number of arguments in a function in Boost.Parameter can be configured using
#define BOOST_PARAMETER_MAX_ARITY n(n=6 in your case) before the inclusion of headers. This parameter had a default value of5before boost 1.49. The value is8after that. I believe increasing this number affects the compile time of your program so you should set it to what you need and not arbitrarily high.