clang-format禁用单行Lambda后产生不必要换行的问题咨询
clang-format禁用单行Lambda后产生不必要换行的问题咨询
我最近在用clang-format格式化C++代码时碰到了个小困扰,想请教下大家有没有解决办法:
我设置了禁用单行Lambda的配置后,链式调用里的Lambda部分被强制换行了,但这个换行完全没必要,反而破坏了代码的连贯性。
先给大家看看我的原代码:
auto transs = transitions | stdv::filter([alph](const auto trns) { return trns.first == alph; }) | stdv::values | stdv::transform([](auto x) { return x; }) | stdv::as_rvalue;
对应的clang-format配置是这样的:
BasedOnStyle: Google AllowShortLambdasOnASingleLine: None BreakBeforeBinaryOperators: NonAssignment
我预期的格式化结果应该是Lambda的函数体部分保持在同一行,不需要额外换行,具体如下:
auto transs = transitions | stdv::filter([alph](const auto trns) { return tr的内容
我本来只是想避免把短Lambda整个挤在一行里,但现在clang-format却在Lambda的左大括号后强制换行了,这个换行完全是多余的。有没有办法调整配置,既能实现禁止单行Lambda的需求,又能避免这种不必要的换行呢?
内容来源于stack exchange
相关产品推荐
相关产品推荐

