
François Duranleau wrote:
On Mon, 1 Oct 2007, David Abrahams wrote:
[...]
See http://boost.org/libs/parameter/doc/html/index.html#adding-type-requirements
I tried this simple example:
//--------------------------------------------- #include <boost/parameter/name.hpp> #include <boost/parameter/preprocessor.hpp>
BOOST_PARAMETER_NAME( (arg1 , kw) arg1 )
BOOST_PARAMETER_FUNCTION( (arg1_type) , the_function , kw , (required (arg1 , *)) ) { return arg1; }
int main() { int i = the_function( 1 ) ; return 0 ; } //---------------------------------------------
but it won't compile either (gcc-4.0.2). Actually, if we look at the preprocessed output, it's not surprising. Here is the part of interest [...]
I looked for examples in Boost.Parameter's test programs, alas, it seems there are no tests written for this feature.
Right. This is a doc error. You need extract the type from the argument pack Args: BOOST_PARAMETER_FUNCTION( (typename boost::parameter::value_type<Args, kw::arg1>::type) , the_function , kw , (required (arg1 , *)) ) { return arg1; } Unfortunately the library has a bug that prevents this from working. This has been fixed, but not in time for 1.34. IIRC you need to apply this patch: http://svn.boost.org/trac/boost/attachment/ticket/1044/parameter.diff for this to work correctly. -- Daniel Wallin Boost Consulting www.boost-consulting.com