Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 铿锵格式:单行上的Lambda不';行不通_C++_Clang Format - Fatal编程技术网

C++ 铿锵格式:单行上的Lambda不';行不通

C++ 铿锵格式:单行上的Lambda不';行不通,c++,clang-format,C++,Clang Format,我使用的是叮当格式,我希望我的lambda在一行上。 我设置了AllowShortLambdasOnASingleLine:All,但格式化时: autol=[](autox){返回2*x;}; 我明白了: auto l=[](auto x) {返回2*x;}; 这当然看起来很奇怪,而且不是预期的行为。 有人知道如何解决这个问题吗 我的完整.clang格式如下所示: --- AccessModifierOffset: -4 AlignAfterOpenBracket: Align Align

我使用的是叮当格式,我希望我的lambda在一行上。 我设置了
AllowShortLambdasOnASingleLine:All
,但格式化时:

autol=[](autox){返回2*x;};
我明白了:

auto l=[](auto x)
{返回2*x;};
这当然看起来很奇怪,而且不是预期的行为。 有人知道如何解决这个问题吗

我的完整
.clang格式
如下所示:

---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: "true"
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: All #NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas:  '^[^ ]'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: NonEmptyParentheses
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: "c++20"
TabWidth: 4
UseTab: Never
---
AlignTrailingComments: true
BasedOnStyle: Chromium
BreakBeforeBraces: Allman
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
Language: ObjC
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
TabWidth: 4
UseTab: Never


我强烈建议您将
.clang格式的文件按字母顺序排列。我正要给你一个油嘴滑舌的回答,说你的文件中没有选项。@sweenish你是对的,我更新了帖子。作为测试,如果你将
breakbeforebrases:Allman
更改为
Attach
,它是否有效?如果是,您可能需要为
BraceWrapping
设置自定义规则,或者使用优先级。@sweenish就是这样做的!非常感谢。我设置了
BreakBeforeBraces:Custom
并添加了自定义
brakewrapping