c++ - 创建一个用于 spirit 规则的凤凰函数

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

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

相关文章:

c++函数模板编译错误 "‘containerType’不是模板”

c++ - 异常是否需要虚拟继承?

c++ - 如何在 C++ 中创建文件映射?

c++ - 将 boost::iostreams::mapped_file_source 与宽字符串一起使用

c++ - qi::rule<It, std::string ()> 不解析输入字符串

c++ - reinterpret_cast 充当 dynamic_cast

c++ - Boost FFT 示例 - 编译时出错,这段代码在做什么?

c++ - 使用复制昂贵的类作为 std::map 中的映射值是否有效?

c++ - boost::spirit::qi 关键字和标识符

c++ - 用灵气解析成 std​​::vector<string>,出现段错误或断言失败