The code below, using boost::spirit, used to work with boost 1.44 and boost 1.49:
qi::string("a_token")
[
boost::phoenix::bind(&node_t::some_func, *qi::_val, true)
]
I updated boost to version 1.53, but now this code does not compile anymore. g++ complains about
error: pointer to member type 'void (node_t::)(bool)' incompatible with object type 'boost::error_cant_deduce_type'
I can't figure out how to fix it. The following code compiles :
qi::string("a_token")
[
boost::phoenix::bind(&node_t::some_func, (node_t*)0, true)
]
So I guess the problem is with qi::val_... Did the API of boost::spirit changed or am I missing an include file ?
I'm using g++4.7, with --std=c++0x.
Here I tried a small test case to reproduce the problem. The error message is not the same (but it's still big !), but once again the dereference operator seems to be the problem.
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/shared_ptr.hpp>
struct node_t
{
void foo(bool){}
};
int main()
{
namespace qi = boost::spirit::qi;
boost::spirit::qi::rule
<
std::string::const_iterator,
boost::shared_ptr<node_t>(),
boost::spirit::ascii::space_type
> rule;
rule = qi::string("true")
[boost::phoenix::bind(&node_t::foo, *qi::_val, true)];
}
This is an answer made from the helpfull comments above (thanks to llonesmiz).
Changes made in boost::shared_ptr
affects old version of boost::pheonix
when trying to use the dereference operator * over a boost::shared_ptr
.
Before including boost::spirit
, #define BOOST_SPIRIT_USE_PHOENIX_V3 1
can be added to the source.
Also, some includes such as #include <boost/spirit/home/phoenix/ ... >
are to be removed because it will conflict with spirit v3
. Instead, include files such as #include <boost/spirit/include/phoenix.hpp>
.