【发布时间】: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