首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么控件在对象的成员函数之前以clang格式中断?

什么控件在对象的成员函数之前以clang格式中断?
EN

Stack Overflow用户
提问于 2018-11-01 16:49:55
回答 1查看 149关注 0票数 2

这是C++代码的一部分,我想用工具进行格式化(7.0.0版)。

代码语言:javascript
复制
template <typename Fn>
void AsyncAPI::init_write(std::string const& data, Fn&& callback)
{
    errorcode injected(injected_);
    injected_ = 0;

    if (!injected) { data_ = data; }
    std::thread([injected, callback = std::forward<Fn>(callback)]() mutable {
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        callback(injected);
    })
        .detach();
}

detach()成员函数的this_thread被移动到一个新的行。我怎么能把它往上移动一条线,看起来就像

代码语言:javascript
复制
std::thread([]() {
/*
*/
}).detach();

我对当前的设置非常满意,所以我希望变化不要太大。我尝试了clang-format (Google,LLVM)提供的预定义格式样式,其中没有一个能够将detach向上移动。

我的clang格式配置文件是,

代码语言:javascript
复制
---
Language:        Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands:   true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BraceWrapping:
  AfterClass: true
  AfterControlStatement: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: true
  BeforeElse: false
  SplitEmptyFunction: true
BreakStringLiterals: true
ColumnLimit:     80
CommentPragmas:  '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat:   false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IndentCaseLabels: false
IndentWidth:     4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd:   ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard:        Cpp11
TabWidth:        4
UseTab:          Never
...
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-26 16:56:24

这似乎是clang-format版本5.0.0中出现的问题,并且修复了10.0.0版本(使用配置器验证)。因此,您最好的选择是迁移到clang-format版本10.0.0或更高版本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53105763

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档