【问题标题】:Create a phoenix function for use in spirit rule创建一个凤凰功能用于精神规则
【发布时间】:2013-03-07 19:44:22
【问题描述】:

我正在尝试编译下面的代码,但是,像往常一样,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() ];
}

【问题讨论】:

  • 您已将 bar::operator() 声明为采用单个参数,但您调用 foo 时没有任何参数...
  • @ildjarn 在operator() 中没有参数就不能更好地工作。
  • 谢谢,就是这样。我真的很接近解决方案......很遗憾编译错误没有帮助。
  • @neodelphi : 如果你使用 clang... ;-]

标签: c++ boost boost-spirit boost-phoenix


【解决方案1】:

正如 ildjarn 所说,对 foo 的调用会遗漏一个参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-28
    相关资源
    最近更新 更多