我正在尝试编译下面的代码,但是,像往常一样,spirit/phoenix 的错误并没有给出很多关于问题所在的线索。谁能看出问题出在哪里?
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/shared_ptr.hpp>
typedef boost::shared_ptr<int> sptr;
struct bar
{
template <typename A> struct result
{
typedef sptr type;
};
template <typename A> sptr operator()(A) const
{
return sptr();
}
};
boost::phoenix::function<bar> foo;
void test()
{
namespace qi = boost::spirit::qi;
using qi::_val;
qi::rule
<
std::string::const_iterator,
sptr(),
boost::spirit::ascii::space_type
>
test_rule = qi::eps [ _val = foo() ];
}
最佳答案
正如 ildjarn 所说,对 foo 的调用遗漏了一个参数。
关于c++ - 创建一个用于 spirit 规则的凤凰函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15280291/