[parameter] compiler errors with operators

Hello all, Does Boost.Parameter support operators? The following example is from the docs but it doesn't compile. Looking at the preprocessed code /EP, the errors seem to be because the macro defines a struct template postfixing it with the operator name and symbol "template <class Args> struct boost_param_result_11operator() { ... };". Maybe this worked once before and it's now broken? #include <boost/parameter.hpp> #include <iostream> BOOST_PARAMETER_NAME(arg1) BOOST_PARAMETER_NAME(arg2) struct callable2 { BOOST_PARAMETER_CONST_MEMBER_FUNCTION( (void), operator(), tag, (required (arg1,(int))(arg2,(int)))) { std::cout << arg1 << ", " << arg2 << std::endl; } }; int main ( void ) { callable2 c; c(1, 2); return 0; } On MSVC 8 with latest Boost trunk: c02.cpp c02.cpp(11) : error C2988: unrecognizable template declaration/definition c02.cpp(11) : error C2059: syntax error : 'type' c02.cpp(11) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body c02.cpp(11) : error C2988: unrecognizable template declaration/definition c02.cpp(11) : error C2059: syntax error : 'type' c02.cpp(11) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body c02.cpp(11) : error C2143: syntax error : missing ';' before '<' c02.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c02.cpp(11) : error C2238: unexpected token(s) preceding ';' c02.cpp(11) : error C2143: syntax error : missing ';' before '<' c02.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c02.cpp(11) : error C2238: unexpected token(s) preceding ';' c02.cpp(11) : error C2988: unrecognizable template declaration/definition c02.cpp(11) : error C2059: syntax error : '<' c02.cpp(11) : error C3861: 'boost_param_parameters_11operator': identifier not found c02.cpp(11) : error C2039: 'type' : is not a member of '`global namespace'' c02.cpp(11) : error C3861: 'boost_param_parameters_11operator': identifier not found c02.cpp(11) : error C2039: 'type' : is not a member of 'boost::parameter::aux::match' ..\..\..\..\..\boost\trunk.windows\boost/parameter/preprocessor.hpp(99) : see declaration of 'boost::parameter::aux::match' c02.cpp(11) : error C2039: 'type' : is not a member of '`global namespace'' c02.cpp(11) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body c02.cpp(14) : error C2270: 'boost_param_default_11operator' : modifiers not allowed on nonmember functions c02.cpp(14) : error C2091: function returns function c02.cpp(20) : error C2064: term does not evaluate to a function taking 2 arguments Thanks. --Lorenzo

on Sun Dec 04 2011, Lorenzo Caminiti <lorcaminiti-AT-gmail.com> wrote:
Hello all,
Does Boost.Parameter support operators?
The following example is from the docs but it doesn't compile.
My guess from what you wrote there is that the legacy interface supports operators but this version of the library never did. I would suggest extending the library to recognize a special function name in place of operator(), and having it generate the function call operator itself. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
Dave Abrahams
-
Lorenzo Caminiti