我编写了下面列出的代码。编译器向我报告一个错误:'3 个重载都不能转换所有参数类型'。
我使用 MSVC 11.0 和 Boost 1.51.0。表达式的每个分支都m_oQueryIterationExpression
可以正常工作,但它们不能一起工作。有什么线索吗?
#include <boost/spirit/include/qi.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/variant/recursive_variant.hpp>
namespace Ns
{
struct Regexp { std::string m_strEntity; };
struct String { std::string m_strEntity; };
struct Identifier { std::string m_strEntity; };
typedef int Number;
typedef std::string Operation;
typedef boost::variant<Regexp, Number, String, Identifier> Operand;
typedef boost::tuple<Operation, boost::optional<std::vector<Operand> > > OperationWithOperands;
struct QueryConcatenation;
typedef boost::tuple<boost::recursive_wrapper<QueryConcatenation>, boost::optional<char> > typeA;
typedef std::vector<std::vector<OperationWithOperands> > typeB;
typedef boost::variant<typeA, typeB> QueryIteration;
struct QueryConcatenation {
typedef std::vector<QueryIteration> TEntity;
TEntity m_oEntity;
};
}
int main()
{
using namespace Ns;
namespace qi = boost::spirit::qi;
qi::rule<char*, QueryConcatenation()> m_oQueryConcatenationExpression;
qi::rule<char*, QueryIteration()> m_oQueryIterationExpression;
qi::rule<char*, std::vector<std::vector<OperationWithOperands> >() > m_oQueryNode;
m_oQueryIterationExpression %=
qi::attr_cast<typeA, typeA>( '(' >> m_oQueryConcatenationExpression >> ')' >> -(qi::char_("*+?")) )
| m_oQueryNode;
}