Boost.Spirit将表达转换为AST
Boost.Spirit transform expression to AST
使用 Boost.Spirit 将某些表达式转换为 AST 的正确方法是什么?
我试图构建它,但我认为它很混乱,可以简化很多。
https://godbolt.org/z/VXHXLY
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
namespace ast {
struct unary_operator;
struct binary_operator;
struct expression {
typedef boost::variant<
double,
std::string,
boost::recursive_wrapper<unary_operator>,
boost::recursive_wrapper<binary_operator>,
boost::recursive_wrapper<expression>
> type;
expression() {
}
template<typename Expr>
expression(const Expr &expr)
: expr(expr) {
}
expression &operator+=(expression rhs);
expression &operator-=(expression rhs);
expression &operator*=(expression rhs);
expression &operator/=(expression rhs);
expression &and_(expression rhs);
expression &or_(expression rhs);
expression &equals(expression rhs);
expression ¬_equals(expression rhs);
expression &less_than(expression rhs);
expression &less_equals(expression rhs);
expression &greater_than(expression rhs);
expression &greater_equals(expression rhs);
expression &factor(expression rhs);
expression &dot(expression rhs);
type expr;
};
struct unary_operator {
std::string op;
expression rhs;
unary_operator() {}
unary_operator(std::string op, expression rhs)
: op(std::move(op)), rhs(std::move(rhs)) {
}
};
struct binary_operator {
std::string op;
expression lhs;
expression rhs;
binary_operator() {}
binary_operator(std::string op, expression lhs, expression rhs)
: op(std::move(op)), lhs(std::move(lhs)), rhs(std::move(rhs)) {
}
};
expression &expression::operator+=(expression rhs) {
expr = binary_operator("+", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::operator-=(expression rhs) {
expr = binary_operator("-", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::operator*=(expression rhs) {
expr = binary_operator("*", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::operator/=(expression rhs) {
expr = binary_operator("/", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::and_(expression rhs) {
expr = binary_operator("&&", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::or_(expression rhs) {
expr = binary_operator("||", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::equals(expression rhs) {
expr = binary_operator("==", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::not_equals(expression rhs) {
expr = binary_operator("!=", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::less_than(expression rhs) {
expr = binary_operator("<", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::less_equals(expression rhs) {
expr = binary_operator("<=", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::greater_than(expression rhs) {
expr = binary_operator(">", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::greater_equals(expression rhs) {
expr = binary_operator(">=", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::factor(expression rhs) {
expr = binary_operator("**", std::move(expr), std::move(rhs));
return *this;
}
expression &expression::dot(expression rhs) {
expr = binary_operator(".", std::move(expr), std::move(rhs));
return *this;
}
struct printer {
void operator()(const double n) const {
std::cout << n;
}
void operator()(const std::string &s) const {
std::cout << s;
}
void operator()(const expression &ast) const {
boost::apply_visitor(*this, ast.expr);
}
void operator()(const binary_operator &expr) const {
std::cout << "op:" << expr.op << "(";
boost::apply_visitor(*this, expr.lhs.expr);
std::cout << ", ";
boost::apply_visitor(*this, expr.rhs.expr);
std::cout << ')';
}
void operator()(const unary_operator &expr) const {
std::cout << "op:" << expr.op << "(";
boost::apply_visitor(*this, expr.rhs.expr);
std::cout << ')';
}
};
struct operators {
struct and_ {
};
struct or_ {
};
struct equals {
};
struct not_equals {
};
struct less_than {
};
struct less_equals {
};
struct greater_than {
};
struct greater_equals {
};
struct factor {
};
struct dot {
};
expression &operator()(expression &lhs, expression rhs, and_) const {
return lhs.and_(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, or_) const {
return lhs.or_(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, equals) const {
return lhs.equals(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, not_equals) const {
return lhs.not_equals(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, less_than) const {
return lhs.less_than(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, less_equals) const {
return lhs.less_equals(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, greater_than) const {
return lhs.greater_than(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, greater_equals) const {
return lhs.greater_equals(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, factor) const {
return lhs.factor(std::move(rhs));
}
expression &operator()(expression &lhs, expression rhs, dot) const {
return lhs.dot(std::move(rhs));
}
};
}
namespace qi = boost::spirit::qi;
struct expectation_handler {
template<typename Iterator>
void operator()(Iterator first, Iterator last, const boost::spirit::info &info) const {
std::stringstream msg;
msg << "Expected " << info << " at "" << std::string(first, last) << """;
throw std::runtime_error(msg.str());
}
};
template<typename Iterator>
struct grammar : qi::grammar<Iterator, ast::expression(), qi::ascii::space_type> {
grammar()
: grammar::base_type(expression) {
variable = qi::lexeme[qi::alpha >> *(qi::alnum | '_')];
expression = logical.alias() > qi::eoi;
logical = equality[qi::_val = qi::_1]
>> *(
((qi::lit("&&") > equality[op(qi::_val, qi::_1, ast::operators::and_{})]) |
(qi::lit("||") > equality[op(qi::_val, qi::_1, ast::operators::or_{})]))
);
equality = relational[qi::_val = qi::_1]
>> *(
((qi::lit("==") > relational[op(qi::_val, qi::_1, ast::operators::equals{})]) |
(qi::lit("!=") > relational[op(qi::_val, qi::_1, ast::operators::not_equals{})]))
);
relational = additive[qi::_val = qi::_1]
>> *(
((qi::lit("<") > relational[op(qi::_val, qi::_1, ast::operators::less_than{})]) |
(qi::lit("<=") > relational[op(qi::_val, qi::_1, ast::operators::less_equals{})]) |
(qi::lit(">") > relational[op(qi::_val, qi::_1, ast::operators::greater_than{})]) |
(qi::lit(">=") > relational[op(qi::_val, qi::_1, ast::operators::greater_equals{})]))
);
additive = multiplicative[qi::_val = qi::_1]
>> *(
((qi::lit("+") > multiplicative[qi::_val += qi::_1]) |
(qi::lit("-") > multiplicative[qi::_val -= qi::_1]))
);
multiplicative = factor[qi::_val = qi::_1]
>> *(
((qi::lit("*") > factor[qi::_val *= qi::_1]) |
(qi::lit("/") > factor[qi::_val /= qi::_1]))
);
factor = primary[qi::_val = qi::_1]
>> *((qi::lit("**")) > primary[op(qi::_val, qi::_1, ast::operators::factor{})]);
primary =
qi::double_[qi::_val = qi::_1]
| ('(' > expression[qi::_val = qi::_1] > ')')
>> *(qi::char_('.') > variable[qi::_val = op(qi::_val, qi::_1, ast::operators::dot{})])
| variable[qi::_val = qi::_1]
>> *(qi::char_('.') > variable[qi::_val = op(qi::_val, qi::_1, ast::operators::dot{})]);
qi::on_error<qi::fail>(
expression,
boost::phoenix::bind(boost::phoenix::ref(err_handler), qi::_3, qi::_2, qi::_4));
}
qi::rule<Iterator, ast::expression(), qi::ascii::space_type> expression, logical, equality, relational, additive, multiplicative, factor, unary, binary, primary;
qi::rule<Iterator, std::string()> variable;
boost::phoenix::function<ast::operators> op;
expectation_handler err_handler;
};
int main(int argc, const char *argv[]) {
std::string input("2 + 5 + t.a");
auto it_begin(input.begin()), it_end(input.end());
grammar<decltype(it_begin)> parser;
ast::expression expression;
qi::phrase_parse(it_begin, it_end, parser, qi::ascii::space, expression);
ast::printer printer;
printer(expression);
return 0;
}
指纹
op:+(op:+(2, 5), op:.(t, a))
我将按照"发现"您的代码的顺序叙述这一点。然后,我将介绍一些我认为最后最重要的调整。
我喜欢你所做的很多事情。
-
一些名称可以(应该?)改进。 例如
ast::operators
没有暗示其目的。它是二进制运算符表达式的懒惰工厂。因此,将其命名为
make_binary
或类似名称。与包装它的
phoenix::function<>
包装器相同。 语义操作中的op
并不能很好地表达那里发生的事情。 -
与其让
op
(别名make_binary
)参与者对_val参数产生副作用,不如考虑使其返回不同的值。然后一切都可以变得不可变,语义操作可以更好地表达意图:rule = expr [ _val = foo(_val, _1, _2, _3) ];
表示_val更新为从给定参数创建的内容。
-
在语法层面上,事情看起来并不"整洁"。很多都可以通过简单地
using namespace qi::labels
来改进,并摆脱多余的qi::lit()
包装器,例如logical = equality[qi::_val = qi::_1] >> *( ((qi::lit("&&") > equality[op(qi::_val, qi::_1, ast::operators::and_{})]) | (qi::lit("||") > equality[op(qi::_val, qi::_1, ast::operators::or_{})])) );
到
using ast::operators; using namespace qi::labels; logical = equality[_val = _1] >> *( (("&&" > equality[op(_val, _1, operators::and_{})]) | ("||" > equality[op(_val, _1, operators::or_{})])) );
-
你检查语法中的
eoi
(对你有好处!但是,它被放在递归规则中:expression = logical.alias() > qi::eoi;
这意味着
(a+b)*3
永远不会解析,因为)
是在需要eoi
的地方找到的。通过将eoi
放在顶层来修复它。 -
你在语法级别有一个船长,这意味着人们必须通过正确的船长。如果他们不这样做,他们可能会破坏语法。相反,将船长设置为内部,以便您控制它,并且界面更易于使用(正确):
start = qi::skip(qi::ascii::space) [ expression ];
用法:
if (qi::parse(it_begin, it_end, parser, expression)) {
或者也许:
if (qi::parse(it_begin, it_end, parser > qi::eoi, expression)) {
-
我意识到驱动程序代码(
main
)可能超出了您的审查范围,但我会向您展示缺少的错误处理,因为它可能是非常微妙的w.r.t.部分解析:int main() { ast::printer printer; grammar<std::string::const_iterator> parser; for (std::string const input : { "2 + 5 + t.a", "(2 + 5) + t.a", // note the removed eoi constraint "2 + 5 * t.a", "2 * 5 - t.a", "partial match", "uhoh *", }) try { std::cout << "----- " << std::quoted(input) << " ---- n"; auto it_begin(input.begin()), it_end(input.end()); ast::expression expression; if (qi::parse(it_begin, it_end, parser, expression)) { printer(expression); std::cout << std::endl; } else { std::cout << "Not matchedn"; } if (it_begin != it_end) { std::string tail(it_begin, it_end); std::cout << "Remaining unparsed input: " << std::quoted(tail) << "n"; } } catch(std::exception const& e) { std::cout << "Exception: " << std::quoted(e.what()) << "n"; } }
-
请注意,除非您命名了规则,否则期望不会提供有用的消息。
Exception: Expected <unnamed-rule> at ""
命名它们的惯用方法是使用 DEBUG 宏:
BOOST_SPIRIT_DEBUG_NODES( (start) (expression)(logical)(equality) (relational)(additive)(multiplicative) (factor)(unary)(binary)(primary) (variable) )
现在:
Exception: Expected <factor> at ""
中场休息:表面变化:住在科里鲁
-
在打印机中有很多重复(
apply_visitor(*this
...),并且由于operator()
,它略低于可读性。我的偏好是中继到call
或apply
函数 -
同样在打印机中,不要对输出流进行硬编码。有一天(TM)你会想要格式化为一个字符串。或
std::cerr
或文件在打印机上组合这些注释:Live On Coliru
struct printer { std::ostream& _os; template <typename T> std::ostream& operator()(T const& v) const { return call(v); } private: std::ostream& call(expression const& ast) const { return boost::apply_visitor(*this, ast.expr); } std::ostream& call(binary_operator const& expr) const { _os << "op:" << expr.op << "("; call(expr.lhs) << ", "; return call(expr.rhs) << ')'; } std::ostream& call(unary_operator const& expr) const { _os << "op:" << expr.op << "("; return call(expr.rhs) << ')'; } template <typename Lit> std::ostream& call(Lit const& v) const { return _os << v; } };
-
这样做的逻辑扩展是使其成为实际的输出操纵器:
std::cout << "Parsed: " << fmt_expr{expression} << std::endl;
同样,Live On Coliru,也再次简化了
printer
访客:std::ostream& call(binary_operator const& expr) const { return _os << "op:" << expr.op << "(" << fmt_expr{expr.lhs} << ", " << fmt_expr{expr.rhs} << ')'; }
-
在 AST 中,将实际运算符动态存储为字符串。在我看来,仅对所有 ast 构建重载(
ast::operator::operator()
以及ast::expr
的所有委托成员)静态编码运算符没有太多价值。相反,每次都传递一个字符串?现在生成器命名空间可以消失,不对称的工厂成员,整个 phoenix 函数是语法本地的:
struct make_binary_f { ast::binary_operator operator()(ast::expression lhs, ast::expression rhs, std::string op) const { return { op, lhs, rhs }; } }; boost::phoenix::function<make_binary_f> make;
另一个中间车站LiveOn Coliru
成就已解锁
代码减少 113 行代码(现在是 218 行而不是 331 行代码)
-
随机点:
variable = qi::lexeme[qi::alpha >> *(qi::alnum | '_')];
'_'
等同于qi::lit('_')
,而不是qi::char_('_')
,所以这将删除所有下划线。使用 char_,或使用raw[]
直接从源迭代器构造参数。 -
现在我们进入细节:我们可以使用自动属性传播来代替
[_val=_1]
(参见Boost Spirit:"语义行为是邪恶的"?operator %=
规则init)。 -
分解出更常见的子表达式。连同上一个项目符号:
primary = qi::double_[_val = _1] | ('(' > expression[_val = _1] > ')') >> *("." > variable[_val = make(_val, _1, ".")]) | variable[_val = _1] >> *("." > variable[_val = make(_val, _1, ".")]);
成为:
primary %= qi::double_ | (('(' > expression > ')') | variable) >> *("." > variable[_val = make(_val, _1, ".")]) ;
-
将变体类型提升到
expression
之外,以便您可以在expression
之前实现递归类型。此外,请考虑从变体 (LSK) 派生expression
。在您的情况下,实际上不需要嵌套表达式,因为一元/二进制节点已经强加了顺序。因此,您的整个 AST 可以是:struct unary_operator; struct binary_operator; typedef boost::variant< double, std::string, boost::recursive_wrapper<unary_operator>, boost::recursive_wrapper<binary_operator> > expr_variant; struct expression : expr_variant { using expr_variant::expr_variant; using expr_variant::operator=; }; struct unary_operator { expression rhs; std::string op; } ; struct binary_operator { expression lhs; expression rhs; std::string op; } ;
-
将
expectation_handler
移动到语法类中(它对其他任何东西都没有用),并可以选择使用 phoenix::function 对其进行现代化?无论如何,由于函子是无状态的,因此无需ref
(当然不是ref
而不是cref
):qi::on_error<qi::fail>( expression, boost::phoenix::bind(expectation_handler{}, _3, _2, _4));
其实,只要做到就好了
auto handler = [](Iterator first, Iterator last, const boost::spirit::info &info) { std::stringstream msg; msg << "Expected " << info << " at "" << std::string(first, last) << """; throw std::runtime_error(msg.str()); }; qi::on_error<qi::fail>( expression, boost::phoenix::bind(handler, _3, _2, _4));
-
小尼特:使用
std::quoted
而不是"假"引用:) -
后期脑电波,你可以提取大部分语义动作:
auto make_bin = _val = px::bind(make_<ast::binary_expr>{}, _val, _2, _1);
只要所有的肢体都是无状态的/按值,这不是问题(与将解析器分配给自动变量相比!现在只需让运算符公开属性:
expression %= equality >> *( (qi::string("&&") > equality)[make_bin] | (qi::string("||") > equality)[make_bin] ); equality %= relational >> *( (qi::string("==") > relational)[make_bin] | (qi::string("!=") > relational)[make_bin] ); relational %= additive >> *( (qi::string("<") > relational)[make_bin] | (qi::string("<=") > relational)[make_bin] | (qi::string(">") > relational)[make_bin] | (qi::string(">=") > relational)[make_bin] ); additive %= multiplicative >> *( (qi::string("+") > multiplicative)[make_bin] | (qi::string("-") > multiplicative)[make_bin] ); multiplicative %= factor >> *( (qi::string("*") > factor)[make_bin] | (qi::string("/") > factor)[make_bin] ); factor %= primary >> *( (qi::string("**") > primary)[make_bin] ); primary %= qi::double_ | (('(' > expression > ')') | variable) >> *(qi::string(".") > variable)[make_bin] ;
-
实际上,刚刚检查并
phoenix::construct
可以进行聚合:auto make_bin = _val = boost::phoenix::construct<ast::binary_expr>(_1, _val, _2);
-
还删除了未使用的
unary_*
机器,将 IO 操纵器移动到io
命名空间(而不是ast
),并在main
驱动程序中重新引入eoi
检查...... -
哎呀,使用一些 c++17,您可以组合每个产品的分支:
auto op = [](auto... sym) { return qi::copy((qi::string(sym) | ...)); }; expression %= equality >> *(op("&&","||") > equality)[make_bin]; equality %= relational >> *(op("==","!=") > relational)[make_bin]; relational %= additive >> *(op("<","<=",">",">=") > relational)[make_bin]; additive %= multiplicative >> *(op("+","-") > multiplicative)[make_bin]; multiplicative %= factor >> *(op("*","/") > factor)[make_bin]; factor %= primary >> *(op("**") > primary)[make_bin];
完整演示,103 行代码
只是没有设法将其降低到 100 LoC 以下,但我在此过程中添加了更多测试用例。
-
魔杖盒上的现场演示
-
编译器资源管理器上的现场演示
-
Coliru 上的现场演示(我发现聚合
phoenix::construct<>
需要 GCC 或最近的提升或两者兼而有之,因此添加了一个构造函数)
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <iostream>
#include <iomanip>
namespace qi = boost::spirit::qi;
namespace ast {
struct binary_expr;
typedef boost::variant<
double,
std::string,
boost::recursive_wrapper<binary_expr>
> expr_variant;
struct expression : expr_variant {
using expr_variant::expr_variant;
using expr_variant::operator=;
};
struct binary_expr {
binary_expr(std::string op, expression lhs, expression rhs)
: op(std::move(op)), lhs(std::move(lhs)), rhs(std::move(rhs)) {}
std::string op; expression lhs; expression rhs;
};
}
namespace io {
struct fmt_expr { // io manipulator
ast::expression const& _ref;
friend std::ostream& operator<<(std::ostream& os, fmt_expr manip);
};
struct formatter_visitor {
std::ostream& _os;
template <typename T> std::ostream& operator()(T const& v) const
{ return call(v); }
private:
std::ostream& call(ast::expression const& v) const {
return boost::apply_visitor(*this, v);
}
std::ostream& call(ast::binary_expr const& expr) const {
return _os << "op:" << expr.op
<< "(" << fmt_expr{expr.lhs} << ", " << fmt_expr{expr.rhs} << ')';
}
template <typename Lit>
std::ostream& call(Lit const& v) const { return _os << v; }
};
std::ostream& operator<<(std::ostream& os, fmt_expr manip) {
return formatter_visitor{os}(manip._ref);
}
}
template<typename Iterator>
struct grammar : qi::grammar<Iterator, ast::expression()> {
grammar() : grammar::base_type(start) {
using namespace qi::labels;
auto make_bin = _val = boost::phoenix::construct<ast::binary_expr>(_1, _val, _2);
auto op = [](auto... sym) { return qi::copy((qi::string(sym) | ...)); };
expression %= equality >> *(op("&&","||") > equality)[make_bin];
equality %= relational >> *(op("==","!=") > relational)[make_bin];
relational %= additive >> *(op("<","<=",">",">=") > relational)[make_bin];
additive %= multiplicative >> *(op("+","-") > multiplicative)[make_bin];
multiplicative %= factor >> *(op("*","/") > factor)[make_bin];
factor %= primary >> *(op("**") > primary)[make_bin];
variable = qi::lexeme[qi::alpha >> *(qi::alnum | qi::char_('_'))];
primary %= qi::double_ | (('(' > expression > ')') | variable)
>> *(op(".") > variable)[make_bin];
start = qi::skip(qi::ascii::space) [ qi::eps > expression ] > qi::eoi;
qi::on_error<qi::fail>(start, boost::phoenix::bind([](auto first, auto last, auto const& info) {
std::stringstream msg;
msg << "Expected " << info << " at " << std::quoted(std::string(first, last));
throw std::runtime_error(msg.str());
}, _3, _2, _4));
BOOST_SPIRIT_DEBUG_NODES((expression)(equality)(relational)(additive)
(multiplicative)(factor)(unary)(binary)(primary)(variable))
}
private:
qi::rule<Iterator, ast::expression()> start;
qi::rule<Iterator, ast::expression(), qi::ascii::space_type> expression, equality, relational, additive, multiplicative, factor, unary, binary, primary;
qi::rule<Iterator, std::string()> variable; // lexeme
};
int main() {
using io::fmt_expr;
grammar<std::string::const_iterator> parser;
for (std::string const s : { "2 + 5 + t.a", "(2 + 5) + t.a", "2 + 5 * t.a",
"2 * 5 - t.a", "partial match", "uhoh *", "under_scores", "" })
try {
ast::expression expression;
qi::parse(s.begin(), s.end(), parser, expression);
std::cout << std::quoted(s) << " -> " << fmt_expr{expression} << "n";
} catch(std::exception const& e) {
std::cout << "Exception: " << e.what() << "n";
}
}
指纹
"2 + 5 + t.a" -> op:+(op:+(2, 5), op:.(t, a))
"(2 + 5) + t.a" -> op:+(op:+(2, 5), op:.(t, a))
"2 + 5 * t.a" -> op:+(2, op:*(5, op:.(t, a)))
"2 * 5 - t.a" -> op:-(op:*(2, 5), op:.(t, a))
Exception: Expected <eoi> at " match"
Exception: Expected <factor> at ""
"under_scores" -> under_scores
超出范围
我将考虑的范围之外的事情与您的语法/ast语义有关。
运算符优先级有点嘈杂。你想要的是一些元数据,允许你"只是组合"二进制操作数并出现正确的优先级,如下所示:
expression %= primary >> *( (binop > expression) [_val = make_bin(_1, _val, _2)] );
我已经在这个答案的扩展聊天中应用了这个策略,结果代码在 github 上: https://github.com/sehe/qi-extended-parser-evaluator
如果您有 C++14 支持,请考虑使用 X3。编译时间会短得多。
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中使用nlohmann从类到json的转换
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 复制列表初始化的隐式转换的等级是多少
- 正在将指针转换为范围
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 是否可以从int转换为enum类类型
- Boost.Spirit将表达转换为AST
- 将z3个c++ API ast(或求解器)对象转换为SMTLIB字符串