gpt4 book ai didi

c++ - 函数参数继续

转载 作者:行者123 更新时间:2023-12-01 14:43:41 25 4
gpt4 key购买 nike

我正在查看Clang-Format Style Options,但找不到以下选项。如果函数及其自变量破坏了ColumnLimit,我想在新行上继续自变量。

// Good
SomeLongFunction(first_argument,
second_argument,
third_argument,
fourth_argument,
fifth_argument);

// Bad
SomeLongFunction(first_argument, second_argument, third_argument,
fourth_argument, fifth_argument);

看来 AlignAfterOpenBracket至少会让我配置决定继续下一行时缩进的位置,但是我找不到让我指定的东西来分解参数。

最佳答案

您可能想要:

BinPackParameters: false

这样,您的不良示例将被格式化为良好示例。文档:

BinPackParameters (bool)

If false, a function declaration’s or function definition’s parameters will either all be on the same line or will have one line each.

true:
void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

false:
void f(int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}


另外:
AllowAllParametersOfDeclarationOnNextLine: false

如果您希望中断所有参数,即使它们在单次中断后适合放在单行中,也可能很有用。说明文件:

AllowAllParametersOfDeclarationOnNextLine (bool)

If the function declaration doesn’t fit on a line, allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false.

true:
void myFunction(
int a, int b, int c, int d, int e);

false:
void myFunction(int a,
int b,
int c,
int d,
int e);

关于c++ - 函数参数继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59629371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com