Matazure
Matazure

Reputation: 43

Boost Spirit Phoenix function error

This code is from the examples for boost spirit libs, it's OK:

on_error<fail>(expr,error_handler_function(eh)("expecting ", _4, _3));

However, this code failed to compile in Xcode:

on_error<fail>(expr,error_handler_function(eh)("expecting ", _4, _3, _1)); 

The error message:

/usr/local/include/boost/spirit/home/phoenix/core/detail/function_eval.hpp:115:30:
    error: too many template arguments for class template 'result'

    fn::template result<BOOST_PP_ENUM_PARAMS(N, a)>
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

The eh(error_handle) is right, I added the argument for the _1.

Upvotes: 1

Views: 116

Answers (1)

sehe
sehe

Reputation: 393829

You added the argument, but failed to add a template argument.

It needs to be a template argument because Phoenix expects fully polymorphic functors.


Potentially (depending on compiler and library versions), you can remove some of the restrictions by using

#define BOOST_SPIRIT_USE_PHOENIX_V3
// and/or
#define BOOST_RESULT_OF_USE_DECLTYPE

Upvotes: 3

Related Questions